class Jsm::EventExecutor::ActiveRecord

Public Instance Methods

execute_action(event, obj) click to toggle source
# File lib/jsm/event_executor/active_record.rb, line 2
def execute_action(event, obj)
  if can_be_executed?(event, obj)
    result = false
    # do transaction to prevent shit happen
    ActiveRecord::Base.transaction do
      obj.class.lock
      event.execute(obj)
      result = obj.save
    end
    result
  else
    false
  end
end