Module: Housekeeping::Users

Extended by:
ActiveSupport::Concern
Included in:
AlternateValue, GeographicArea, GeographicAreaType, GeographicItem, Language, Namespace, Person, PreparationType, Project, ProjectMember, Repository, Role, Role::SourceRole, Serial, SerialChronology, Source, SourceSource, User
Defined in:
lib/housekeeping/users.rb

Overview

Concern that provides housekeeping and related methods for models that belong_to a creator and updator

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) by

A convienience. When provided creator and updater are set. If creator exists updater is set. Overrides creator/updater if provided second. See tests.

Otu.new(name: 'Aus', by: @user)


48
49
50
# File 'lib/housekeeping/users.rb', line 48

def by
  @by
end

Instance Method Details

- (Object) set_created_by_id (protected)



62
63
64
# File 'lib/housekeeping/users.rb', line 62

def set_created_by_id
  self.created_by_id ||= $user_id
end

- (Object) set_updated_by_id (protected)



66
67
68
69
70
# File 'lib/housekeeping/users.rb', line 66

def set_updated_by_id 
  if (self.changed? || self.new_record?) && !self.updated_by_id_changed? && self.by.blank?
    self.updated_by_id = $user_id
  end
end