Module: Lockdown::Model::InstanceMethods
- Defined in:
- lib/lockdown/model.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_with_stamps ⇒ Object (also: #create)
- #current_profile_id ⇒ Object
- #update_with_stamps ⇒ Object (also: #update)
Class Method Details
.included(base) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/lockdown/model.rb', line 8 def self.included(base) base.class_eval do alias :create_without_stamps :create alias :update_without_stamps :update end end |
Instance Method Details
#create_with_stamps ⇒ Object Also known as: create
20 21 22 23 24 25 |
# File 'lib/lockdown/model.rb', line 20 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
15 16 17 |
# File 'lib/lockdown/model.rb', line 15 def current_profile_id Thread.current[:profile_id] end |
#update_with_stamps ⇒ Object Also known as: update
28 29 30 31 32 |
# File 'lib/lockdown/model.rb', line 28 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 |