Flowdock
method

fire_event

Importance_0
v2.3.8 - Show latest stable - 0 notes - Class: ActiveModel::StateMachine::Machine
fire_event(event, record, persist, *args) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activemodel/lib/active_model/state_machine/machine.rb, line 26
      def fire_event(event, record, persist, *args)
        state_index[record.current_state(@name)].call_action(:exit, record)
        if new_state = @events[event].fire(record, *args)
          state_index[new_state].call_action(:enter, record)

          if record.respond_to?(event_fired_callback)
            record.send(event_fired_callback, record.current_state, new_state)
          end

          record.current_state(@name, new_state, persist)
          record.send(@events[event].success) if @events[event].success
          true
        else
          if record.respond_to?(event_failed_callback)
            record.send(event_failed_callback, event)
          end

          false
        end
      end
Register or log in to add new notes.