class ActionFlow::Flow::State
Attributes
variables[R]
Public Class Methods
from_session_object(flow_name, data)
click to toggle source
# File lib/action_flow/flow/state.rb, line 53 def self.from_session_object(flow_name, data) instance = new(flow_name) instance.instance_eval do @index = data[0] @max_index = data[1] @variables = data[2] @complete = data[3] end instance end
new(flow_name)
click to toggle source
# File lib/action_flow/flow/state.rb, line 7 def initialize(flow_name) @name = flow_name @flow = ActionFlow.flows[flow_name] @index = 0 @max_index = 0 @variables = {} @complete = false @terminated = false end
Public Instance Methods
complete?()
click to toggle source
# File lib/action_flow/flow/state.rb, line 37 def complete? @complete end
match_distance(context)
click to toggle source
# File lib/action_flow/flow/state.rb, line 17 def match_distance(context) @flow.match_distance(@index, context) end
next_action(params = {})
click to toggle source
# File lib/action_flow/flow/state.rb, line 45 def next_action(params = {}) @flow.action_at(@index + 1, variables, params) end
progress!(context)
click to toggle source
# File lib/action_flow/flow/state.rb, line 21 def progress!(context) if @flow.terminates_on?(context) @terminated = true return end @index += 1 if @flow.match_at?(@index + 1, context) @max_index = [@max_index, @index].max return if current_matches?(context) 0.upto(@max_index) do |backtrack| @index = backtrack if @flow.match_at?(backtrack, context) end @complete = true if @index == @flow.length - 1 end
terminated?()
click to toggle source
# File lib/action_flow/flow/state.rb, line 41 def terminated? @terminated end
to_session_object()
click to toggle source
# File lib/action_flow/flow/state.rb, line 49 def to_session_object [@index, @max_index, @variables, @complete] end
Private Instance Methods
current_matches?(context)
click to toggle source
# File lib/action_flow/flow/state.rb, line 66 def current_matches?(context) @flow.match_at?(@index, context) end