class ActionAudit::EventProcessor
Public Class Methods
new(store)
click to toggle source
# File lib/action_audit/event_processor.rb, line 4 def initialize(store) @store = store @params = {} end
Public Instance Methods
add_change(entity, was, become)
click to toggle source
# File lib/action_audit/event_processor.rb, line 9 def add_change(entity, was, become) info "adding changeset for entity #{entity}" changes_state.trigger(:entity_changed) @store.save_change(@action_id, entity, was, become) end
add_params(params)
click to toggle source
# File lib/action_audit/event_processor.rb, line 15 def add_params(params) @params.merge!(params) changes_state.trigger(:params_added) end
Private Instance Methods
changes_state()
click to toggle source
# File lib/action_audit/event_processor.rb, line 22 def changes_state @changes_state ||= MicroMachine.new(:nothing).tap do |m| m.when(:entity_changed, :nothing => :changed) m.when(:params_added, :changed => :changed) m.on(:changed) do @action_id = @store.upsert_action(@params, @action_id) end end end