class Seam::Flow
Attributes
stamp_data_history[RW]
Public Class Methods
new()
click to toggle source
# File lib/seam/flow.rb, line 6 def initialize @steps = [] @stamp_data_history = false end
Public Instance Methods
method_missing(meth, *args, &blk)
click to toggle source
# File lib/seam/flow.rb, line 11 def method_missing(meth, *args, &blk) meth = meth.to_s @steps << { name: meth, arguments: args } true end
start(data = {})
click to toggle source
# File lib/seam/flow.rb, line 17 def start(data = {}) Seam::Effort.create( { id: SecureRandom.uuid.to_s, created_at: Time.parse(Time.now.to_s), next_execute_at: Time.parse(Time.now.to_s), next_step: self.steps.first.name.to_s, flow: the_flow_from, data: ActiveSupport::HashWithIndifferentAccess.new(data) } ) end
steps()
click to toggle source
# File lib/seam/flow.rb, line 44 def steps @steps.each.map do |step| Seam::Step.new( { name: step[:name], type: 'do', arguments: step[:arguments] } ) end end
the_flow_from()
click to toggle source
# File lib/seam/flow.rb, line 28 def the_flow_from hash = self.to_hash flow = ActiveSupport::HashWithIndifferentAccess.new hash flow['steps'].each do |step| step['id'] = SecureRandom.uuid.to_s end flow end
to_hash()
click to toggle source
# File lib/seam/flow.rb, line 37 def to_hash { steps: self.steps.map { |x| x.to_hash }, stamp_data_history: @stamp_data_history } end