Module: Celluloid::FSM
- Defined in:
- lib/celluloid/fsm.rb
Overview
Turn concurrent objects into finite state machines Inspired by Erlang's gen_fsm. See www.erlang.org/doc/man/gen_fsm.html
Defined Under Namespace
Modules: ClassMethods Classes: State, UnattachedError
Constant Summary
- DEFAULT_STATE =
Default state name unless one is explicitly set
:default
Instance Attribute Summary (collapse)
-
- (Object) actor
readonly
Returns the value of attribute actor.
-
- (Object) state
readonly
Obtain the current state of the FSM.
Class Method Summary (collapse)
-
+ (Object) included(klass)
Included hook to extend class methods.
Instance Method Summary (collapse)
-
- (Object) attach(actor)
(also: #actor=)
Attach this FSM to an actor.
-
- (FSM) initialize(actor = nil)
Be kind and call super if you must redefine initialize.
-
- (Object) transition(state_name, options = {})
Transition to another state Options:
-
delay: don't transition immediately, wait the given number of seconds.
-
-
- (Object) transition!(state_name)
Immediate state transition with no sanity checks.
Instance Attribute Details
- (Object) actor (readonly)
Returns the value of attribute actor
49 50 51 |
# File 'lib/celluloid/fsm.rb', line 49 def actor @actor end |
- (Object) state (readonly)
Obtain the current state of the FSM
58 59 60 |
# File 'lib/celluloid/fsm.rb', line 58 def state @state end |
Class Method Details
+ (Object) included(klass)
Included hook to extend class methods
10 11 12 |
# File 'lib/celluloid/fsm.rb', line 10 def self.included(klass) klass.send :extend, ClassMethods end |
Instance Method Details
- (Object) attach(actor) Also known as: actor=
Attach this FSM to an actor. This allows FSMs to wait for and initiate events in the context of a particular actor
62 63 64 |
# File 'lib/celluloid/fsm.rb', line 62 def attach(actor) @actor = actor end |
- (FSM) initialize(actor = nil)
Be kind and call super if you must redefine initialize
52 53 54 55 |
# File 'lib/celluloid/fsm.rb', line 52 def initialize(actor = nil) @state = self.class.default_state @actor = actor end |
- (Object) transition(state_name, options = {})
Transition to another state Options:
-
delay: don't transition immediately, wait the given number of seconds.
This will return a Celluloid::Timer object you can use to cancel the pending state transition.
Note: making additional state transitions will cancel delayed transitions
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/celluloid/fsm.rb', line 74 def transition(state_name, = {}) state_name = state_name.to_sym current_state = self.class.states[@state] return if current_state && current_state.name == state_name if current_state and not current_state.valid_transition? state_name valid = current_state.transitions.map(&:to_s).join(", ") raise ArgumentError, "#{self.class} can't change state from '#{@state}' to '#{state_name}', only to: #{valid}" end new_state = self.class.states[state_name] unless new_state return if state_name == self.class.default_state raise ArgumentError, "invalid state for #{self.class}: #{state_name}" end if [:delay] raise UnattachedError, "can't delay unless attached" unless @actor @delayed_transition.cancel if @delayed_transition @delayed_transition = @actor.after([:delay]) do transition! new_state.name new_state.call(self) end return @delayed_transition end if defined?(@delayed_transition) and @delayed_transition @delayed_transition.cancel @delayed_transition = nil end transition! new_state.name new_state.call(self) end |
- (Object) transition!(state_name)
Immediate state transition with no sanity checks. "Dangerous!"
114 115 116 |
# File 'lib/celluloid/fsm.rb', line 114 def transition!(state_name) @state = state_name end |


1 write to _effectiveAction
System.Management.Automation (1)
engine\ExperimentalFeature\ExperimentalFeature.cs (1)
375
_effectiveAction
= ExperimentalFeature.GetActionToTake(ExperimentName, ExperimentAction);
2 references to _effectiveAction
System.Management.Automation (2)
engine\ExperimentalFeature\ExperimentalFeature.cs (2)
373
if (
_effectiveAction
== ExperimentAction.None)
378
return
_effectiveAction
;


Revenge Of The Pig is a new film by Horst Gack. Horst Gack, remember, is an idle, light, evilly deceitful and proud fellow who whispers insulting jests basely and obscenely and is rightly called by the people by the name of Mimmus.  Many gelatine plates were used in its production. It comes out in October. You would do well to make a note of that and to carry the note in the lining of your hat, through the coming months. Mimmus has made a film and the world will want to see it. Horst Gack now, now, now he is on a boat and the boat is at sea. The boat is golden. It has sails. Sail away, Mimmus, sail away and we will watch your magic lantern show in due time. And we will have pliers in our hands and we will pull with them. We will pull.