Class: Stateflow::State
- Inherits:
-
Object
- Object
- Stateflow::State
- Defined in:
- lib/stateflow/state.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #enter(method = nil, &block) ⇒ Object
- #execute_action(action, base) ⇒ Object
- #exit(method = nil, &block) ⇒ Object
-
#initialize(name, &options) ⇒ State
constructor
A new instance of State.
Constructor Details
#initialize(name, &options) ⇒ State
Returns a new instance of State.
5 6 7 8 9 10 |
# File 'lib/stateflow/state.rb', line 5 def initialize(name, &) @name = name @options = Hash.new instance_eval(&) if block_given? end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/stateflow/state.rb', line 3 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/stateflow/state.rb', line 3 def @options end |
Instance Method Details
#enter(method = nil, &block) ⇒ Object
12 13 14 |
# File 'lib/stateflow/state.rb', line 12 def enter(method = nil, &block) @options[:enter] = method.nil? ? block : method end |
#execute_action(action, base) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/stateflow/state.rb', line 20 def execute_action(action, base) action = @options[action.to_sym] case action when Symbol, String base.send(action) when Proc action.call(base) end end |
#exit(method = nil, &block) ⇒ Object
16 17 18 |
# File 'lib/stateflow/state.rb', line 16 def exit(method = nil, &block) @options[:exit] = method.nil? ? block : method end |