Module: Yasm::Context::ClassMethods
- Defined in:
- lib/yasm/context.rb
Instance Method Summary collapse
- #after_action(method, options = {}) ⇒ Object
- #before_action(method, options = {}) ⇒ Object
-
#start(state) ⇒ Object
for a simple, anonymous state.
-
#state(name, &block) ⇒ Object
for a named state.
-
#state_configurations ⇒ Object
state configuration metadata.
Instance Method Details
#after_action(method, options = {}) ⇒ Object
11 12 13 |
# File 'lib/yasm/context.rb', line 11 def after_action(method, ={}) state_configuration(ANONYMOUS_STATE).after_action method, end |
#before_action(method, options = {}) ⇒ Object
15 16 17 |
# File 'lib/yasm/context.rb', line 15 def before_action(method, ={}) state_configuration(ANONYMOUS_STATE).before_action method, end |
#start(state) ⇒ Object
for a simple, anonymous state
20 21 22 |
# File 'lib/yasm/context.rb', line 20 def start(state) state_configuration(ANONYMOUS_STATE).start state end |
#state(name, &block) ⇒ Object
for a named state
25 26 27 28 29 30 31 32 33 |
# File 'lib/yasm/context.rb', line 25 def state(name, &block) raise ArgumentError, "The state name must respond to `to_sym`" unless name.respond_to?(:to_sym) name = name.to_sym state_configuration(name).instance_eval &block raise "You must provide a start state for #{name}" unless state_configuration(name).start_state define_method(name) { state_container name } end |
#state_configurations ⇒ Object
state configuration metadata
36 37 38 |
# File 'lib/yasm/context.rb', line 36 def state_configurations @state_configurations ||= {} end |