Class: UserActionObserver
- Inherits:
-
ActiveRecord::Observer
- Object
- ActiveRecord::Observer
- UserActionObserver
- Defined in:
- app/models/user_action_observer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #before_create(model) ⇒ Object
- #before_update(model) ⇒ Object
- #current_user ⇒ Object
- #current_user=(user) ⇒ Object
Class Method Details
.current_user ⇒ Object
14 15 16 |
# File 'app/models/user_action_observer.rb', line 14 def self.current_user Thread.current[:current_user] end |
.current_user=(user) ⇒ Object
7 8 9 |
# File 'app/models/user_action_observer.rb', line 7 def self.current_user=(user) Thread.current[:current_user] = user end |
Instance Method Details
#before_create(model) ⇒ Object
18 19 20 |
# File 'app/models/user_action_observer.rb', line 18 def before_create(model) model.created_by = self.current_user end |
#before_update(model) ⇒ Object
22 23 24 |
# File 'app/models/user_action_observer.rb', line 22 def before_update(model) model.updated_by = self.current_user end |
#current_user ⇒ Object
11 12 13 |
# File 'app/models/user_action_observer.rb', line 11 def current_user self.class.current_user end |
#current_user=(user) ⇒ Object
4 5 6 |
# File 'app/models/user_action_observer.rb', line 4 def current_user=(user) self.class.current_user = user end |