class Mongoid::History::Sweeper

Public Class Methods

observed_classes() click to toggle source
# File lib/mongoid/history/sweeper.rb, line 11
def self.observed_classes
  [Mongoid::History.tracker_class]
end

Public Instance Methods

after(controller) click to toggle source

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

# File lib/mongoid/history/sweeper.rb, line 28
def after(controller)
  self.controller = nil
end
before(controller) click to toggle source

Hook to ActionController::Base#around_filter. Runs before a controller action is run. It should always return true so controller actions can continue.

# File lib/mongoid/history/sweeper.rb, line 19
def before(controller)
  self.controller = controller
  true
end
before_create(track) click to toggle source
# File lib/mongoid/history/sweeper.rb, line 32
def before_create(track)
  modifier_field = track.trackable.history_trackable_options[:modifier_field]
  modifier = track.trackable.send modifier_field
  track.modifier = current_user unless modifier
end
controller() click to toggle source
# File lib/mongoid/history/sweeper.rb, line 3
def controller
  Thread.current[:mongoid_history_sweeper_controller]
end
controller=(value) click to toggle source
# File lib/mongoid/history/sweeper.rb, line 7
def controller=(value)
  Thread.current[:mongoid_history_sweeper_controller] = value
end
current_user() click to toggle source
# File lib/mongoid/history/sweeper.rb, line 38
def current_user
  if controller.respond_to?(Mongoid::History.current_user_method, true)
    controller.send Mongoid::History.current_user_method
  end
end