Module: Skr::Concerns::StateMachine::InstanceMethods
- Defined in:
- lib/skr/concerns/state_machine.rb
Instance Method Summary collapse
- #fire_state_machine_event_on_save ⇒ Object
-
#valid_state_events ⇒ Array of symbols
The available state_transistions.
Instance Method Details
#fire_state_machine_event_on_save ⇒ Object
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_events ⇒ Array of symbols
Returns the available state_transistions.
57 58 59 |
# File 'lib/skr/concerns/state_machine.rb', line 57 def valid_state_events aasm.events end |