Module: SassListen::FSM
- Included in:
- Listener
- Defined in:
- lib/sass-listen/fsm.rb
Defined Under Namespace
Modules: ClassMethods Classes: State
Constant Summary collapse
- DEFAULT_STATE =
Default state name unless one is explicitly set
:default
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Obtain the current state of the FSM.
Class Method Summary collapse
-
.included(klass) ⇒ Object
Included hook to extend class methods.
Instance Method Summary collapse
-
#initialize ⇒ Object
Be kind and call super if you must redefine initialize.
- #transition(state_name) ⇒ Object
-
#transition!(state_name) ⇒ Object
Immediate state transition with no checks, or callbacks.
Instance Attribute Details
#state ⇒ Object (readonly)
Obtain the current state of the FSM
52 53 54 |
# File 'lib/sass-listen/fsm.rb', line 52 def state @state end |
Class Method Details
.included(klass) ⇒ Object
Included hook to extend class methods
7 8 9 |
# File 'lib/sass-listen/fsm.rb', line 7 def self.included(klass) klass.send :extend, ClassMethods end |
Instance Method Details
#initialize ⇒ Object
Be kind and call super if you must redefine initialize
47 48 49 |
# File 'lib/sass-listen/fsm.rb', line 47 def initialize @state = self.class.default_state end |
#transition(state_name) ⇒ Object
54 55 56 57 58 |
# File 'lib/sass-listen/fsm.rb', line 54 def transition(state_name) new_state = validate_and_sanitize_new_state(state_name) return unless new_state transition_with_callbacks!(new_state) end |
#transition!(state_name) ⇒ Object
Immediate state transition with no checks, or callbacks. “Dangerous!”
61 62 63 |
# File 'lib/sass-listen/fsm.rb', line 61 def transition!(state_name) @state = state_name end |