lib/gush/job.rb in gush-0.3 vs lib/gush/job.rb in gush-0.3.1

- old
+ new

@@ -1,10 +1,10 @@ module Gush class Job attr_accessor :workflow_id, :incoming, :outgoing, :params, - :finished_at, :failed_at, :started_at, :enqueued_at, :payloads - attr_reader :name, :output_payload, :params + :finished_at, :failed_at, :started_at, :enqueued_at, :payloads_hash, :klass + attr_reader :name, :output_payload, :params, :payloads def initialize(workflow, opts = {}) @workflow = workflow options = opts.dup assign_variables(options) @@ -35,10 +35,16 @@ def output(data) @output_payload = data end + def payloads + payload_h = {} + payloads_hash.each {|k,val| payload_h[k.to_s] = val.map {|h| h[:payload] }} + payload_h + end + def work end def start! @started_at = current_timestamp @@ -96,10 +102,14 @@ def has_no_dependencies? incoming.empty? end private + def logger + Sidekiq.logger + end + def current_timestamp Time.now.to_i end def assign_variables(opts) @@ -109,9 +119,10 @@ @failed_at = opts[:failed_at] @finished_at = opts[:finished_at] @started_at = opts[:started_at] @enqueued_at = opts[:enqueued_at] @params = opts[:params] || {} + @klass = opts[:klass] @output_payload = opts[:output_payload] end end end