Module: Housekeeping::Users
- Extended by:
- ActiveSupport::Concern
- Included in:
- GeographicArea, GeographicAreaType, GeographicItem, Language, Namespace, Organization, Person, PreparationType, Project, ProjectMember, Repository, Role, Role::SourceRole, Serial, SerialChronology, Source, 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
-
#by ⇒ Object
A convenience.
Instance Method Summary collapse
- #set_created_by_id ⇒ Object protected
-
#set_updated_by_id ⇒ Object
protected
TODO: This method _is not_ called in an ‘after_save’ operation (in User), so this deprecation warning does not apply (?) It may be called in an ‘after_save’ situation through some other model.
Instance Attribute Details
#by ⇒ Object
A convenience. 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)
53 54 55 |
# File 'lib/housekeeping/users.rb', line 53 def by @by end |
Instance Method Details
#set_created_by_id ⇒ Object (protected)
68 69 70 |
# File 'lib/housekeeping/users.rb', line 68 def set_created_by_id self.created_by_id ||= Current.user_id end |
#set_updated_by_id ⇒ Object (protected)
TODO: This method _is not_ called in an ‘after_save’ operation (in User), so this deprecation warning does not apply (?) It may be called in an ‘after_save’ situation through some other model. It may help to unwind the logic. WRT .changed? vs .saved_changes? Deprecation warning
76 77 78 79 80 |
# File 'lib/housekeeping/users.rb', line 76 def set_updated_by_id if (changed? || new_record?) && !updated_by_id_changed? && by.blank? self.updated_by_id = Current.user_id end end |