Class: Stateflow::State
- Inherits:
-
Object
- Object
- Stateflow::State
- Defined in:
- lib/stateflow/state.rb
Instance Attribute Summary (collapse)
-
- (Object) name
Returns the value of attribute name.
-
- (Object) options
Returns the value of attribute options.
Instance Method Summary (collapse)
- - (Object) enter(method = nil, &block)
- - (Object) execute_action(action, base)
- - (Object) exit(method = nil, &block)
-
- (State) initialize(name, &options)
constructor
A new instance of State.
Constructor Details
- (State) initialize(name, &options)
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
- (Object) name
Returns the value of attribute name
3 4 5 |
# File 'lib/stateflow/state.rb', line 3 def name @name end |
- (Object) options
Returns the value of attribute options
3 4 5 |
# File 'lib/stateflow/state.rb', line 3 def @options end |
Instance Method Details
- (Object) enter(method = nil, &block)
12 13 14 |
# File 'lib/stateflow/state.rb', line 12 def enter(method = nil, &block) @options[:enter] = method.nil? ? block : method end |
- (Object) execute_action(action, base)
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 |
- (Object) exit(method = nil, &block)
16 17 18 |
# File 'lib/stateflow/state.rb', line 16 def exit(method = nil, &block) @options[:exit] = method.nil? ? block : method end |