Class: StateMachine::NotificationTransition
- Inherits:
-
Transition
- Object
- Transition
- StateMachine::NotificationTransition
- Defined in:
- lib/motion-state-machine/transition.rb
Overview
Triggered on a specified NSNotification name. Created when supplying an :on_notification option in the transition definition.
On entering the source state, the transition registers itself as NSNotification observer on the default NSNotificationCenter. It deregisters when the state is exited.
Instance Attribute Summary
Attributes inherited from Transition
#destination_state, #event_trigger_value, #options, #source_state, #state_machine
Instance Method Summary collapse
- #arm ⇒ Object
- #event_description ⇒ Object
-
#initialize(options) ⇒ NotificationTransition
constructor
A new instance of NotificationTransition.
- #unarm ⇒ Object
Methods inherited from Transition
#allowed?, #inspect, make, types
Constructor Details
#initialize(options) ⇒ NotificationTransition
Returns a new instance of NotificationTransition.
368 369 370 |
# File 'lib/motion-state-machine/transition.rb', line 368 def initialize() super end |
Instance Method Details
#arm ⇒ Object
376 377 378 379 380 381 382 |
# File 'lib/motion-state-machine/transition.rb', line 376 def arm NSNotificationCenter.defaultCenter.addObserver self, selector: :handle_in_initial_queue, name:event_trigger_value, object:nil @state_machine.log "Registered notification #{event_trigger_value}" end |
#event_description ⇒ Object
372 373 374 |
# File 'lib/motion-state-machine/transition.rb', line 372 def event_description "after getting a #{event_trigger_value}" end |
#unarm ⇒ Object
384 385 386 387 |
# File 'lib/motion-state-machine/transition.rb', line 384 def unarm NSNotificationCenter.defaultCenter.removeObserver self @state_machine.log "Removed as observer" end |