Module: Lockdown::Model::InstanceMethods
- Defined in:
- lib/lockdown/model.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/lockdown/model.rb', line 8 def self.included(base) base.class_eval do alias_method :create_without_stamps, :create alias_method :create, :create_with_stamps alias_method :update_without_stamps, :update alias_method :update, :update_with_stamps end end |
Instance Method Details
#create_with_stamps ⇒ Object
22 23 24 25 26 27 |
# File 'lib/lockdown/model.rb', line 22 def create_with_stamps profile_id = current_profile_id || Profile::SYSTEM self[:created_by] = profile_id if self.respond_to?(:created_by) self[:updated_by] = profile_id if self.respond_to?(:updated_by) create_without_stamps end |
#current_profile_id ⇒ Object
17 18 19 |
# File 'lib/lockdown/model.rb', line 17 def current_profile_id Thread.current[:profile_id] end |
#update_with_stamps ⇒ Object
29 30 31 32 33 |
# File 'lib/lockdown/model.rb', line 29 def update_with_stamps profile_id = current_profile_id || Profile::SYSTEM self[:updated_by] = profile_id if self.respond_to?(:updated_by) update_without_stamps end |