class Seam::Effort

Attributes

complete[RW]
completed_at[RW]
completed_steps[RW]
created_at[RW]
data[RW]
flow[RW]
history[RW]
id[RW]
next_execute_at[RW]
next_step[RW]

Public Class Methods

create(args) click to toggle source
# File lib/seam/effort.rb, line 48
def self.create args
  effort = Seam::Effort.new args
  effort.save
  effort
end
find(effort_id) click to toggle source
# File lib/seam/effort.rb, line 16
def find effort_id
  Seam::Persistence.find_by_effort_id effort_id
end
find_all_by_step(step) click to toggle source
# File lib/seam/effort.rb, line 20
def find_all_by_step step
  Seam::Persistence.find_all_pending_executions_by_step step
end
new(args = {}) click to toggle source
# File lib/seam/effort.rb, line 41
def initialize(args = {})
  @completed_steps = []
  @history         = []
  @complete        = false
  args.each { |k, v| self.send "#{k}=".to_sym, v }
end
parse(document) click to toggle source
# File lib/seam/effort.rb, line 24
def parse document
  Effort.new( {
                id:              document['id'],
                created_at:      Time.parse(document['created_at'].to_s),
                next_execute_at: document['next_execute_at'],
                next_step:       document['next_step'],
                flow:            HashWithIndifferentAccess.new(document['flow']),
                data:            HashWithIndifferentAccess.new(document['data']),
                history:         document['history'].map { |x| HashWithIndifferentAccess.new x },
                completed_steps: document['completed_steps'],
                complete:        document['complete'],
                completed_at:    document['completed_at']
              } )
end

Public Instance Methods

clone() click to toggle source
# File lib/seam/effort.rb, line 82
def clone
  Seam::Effort.parse HashWithIndifferentAccess.new(self.to_hash)
end
complete?() click to toggle source
# File lib/seam/effort.rb, line 63
def complete?
  complete
end
save() click to toggle source
# File lib/seam/effort.rb, line 54
def save
  existing_record = Seam::Effort.find self.id
  if existing_record
    Seam::Persistence.save self
  else
    Seam::Persistence.create self
  end
end
to_hash() click to toggle source
# File lib/seam/effort.rb, line 67
def to_hash
  {
    id:              self.id,
    created_at:      self.created_at,
    completed_steps: self.completed_steps,
    completed_at:    self.completed_at,
    next_execute_at: self.next_execute_at,
    next_step:       self.next_step,
    flow:            self.flow,
    data:            self.data,
    history:         self.history,
    complete:        self.complete,
  }
end