Module: Skr::Concerns::StateMachine::InstanceMethods

Defined in:
lib/skr/concerns/state_machine.rb

Instance Method Summary collapse

Instance Method Details

#fire_state_machine_event_on_saveObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/skr/concerns/state_machine.rb', line 45

def fire_state_machine_event_on_save
    return unless state_event.present?
    event_name = state_event.to_sym
    if valid_state_events.include?( event_name )
        self.send( :aasm_fire_event, event_name,  {:persist=>false} )
    else
        errors.add(:state_event, "is not valid")
        false
    end
end

#valid_state_eventsArray of symbols

Returns the available state_transistions.

Returns:

  • (Array of symbols)

    the available state_transistions



57
58
59
# File 'lib/skr/concerns/state_machine.rb', line 57

def valid_state_events
    aasm.events
end