class States::Dsl::ExecutionContext
Attributes
context[R]
resource_defaults[R]
Public Class Methods
new(context, options)
click to toggle source
# File lib/states/dsl/execution_context.rb, line 7 def initialize(context, options) @context = if context.nil? Context.new(options) else context.create_sub_context end if start_at = options[:start_at] @start_at = @context.naming.ref(start_at) end @states = [] end
Public Instance Methods
serializable_hash()
click to toggle source
# File lib/states/dsl/execution_context.rb, line 31 def serializable_hash { "StartAt" => @start_at, "States" => @states.reduce({}) { |m,s| m[s.name.to_s] = s.serializable_hash; m } } end
start(name, options={}, &block)
click to toggle source
# File lib/states/dsl/execution_context.rb, line 26 def start(name, options={}, &block) @start_at = @context.naming.ref(name) state(name, options, &block) end
state(name, options={}, &block)
click to toggle source
# File lib/states/dsl/execution_context.rb, line 19 def state(name, options={}, &block) state = State.new(name, @context, options) state.instance_eval(&block) if block @states << state state end