Class: Mongoid::History::Sweeper
- Inherits:
-
Observer
- Object
- Observer
- Mongoid::History::Sweeper
- Defined in:
- lib/mongoid/history/sweeper.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#after(controller) ⇒ Object
Hook to ActionController::Base#around_filter.
-
#before(controller) ⇒ Object
Hook to ActionController::Base#around_filter.
- #before_create(track) ⇒ Object
- #controller ⇒ Object
- #controller=(value) ⇒ Object
- #current_user ⇒ Object
Class Method Details
.observed_classes ⇒ Object
11 12 13 |
# File 'lib/mongoid/history/sweeper.rb', line 11 def self.observed_classes [Mongoid::History.tracker_class] end |
Instance Method Details
#after(controller) ⇒ Object
Hook to ActionController::Base#around_filter. Runs after a controller action is run. Clean up so that the controller can be collected after this request
28 29 30 |
# File 'lib/mongoid/history/sweeper.rb', line 28 def after(controller) self.controller = nil end |
#before(controller) ⇒ Object
Hook to ActionController::Base#around_filter. Runs before a controller action is run. It should always return true so controller actions can continue.
19 20 21 22 |
# File 'lib/mongoid/history/sweeper.rb', line 19 def before(controller) self.controller = controller true end |
#before_create(track) ⇒ Object
32 33 34 35 36 |
# File 'lib/mongoid/history/sweeper.rb', line 32 def before_create(track) modifier_field = track.trackable.[:modifier_field] modifier = track.trackable.send modifier_field track.modifier = current_user unless modifier end |
#controller ⇒ Object
3 4 5 |
# File 'lib/mongoid/history/sweeper.rb', line 3 def controller Thread.current[:mongoid_history_sweeper_controller] end |
#controller=(value) ⇒ Object
7 8 9 |
# File 'lib/mongoid/history/sweeper.rb', line 7 def controller=(value) Thread.current[:mongoid_history_sweeper_controller] = value end |