lib/dirty_pipeline/event.rb in dirty_pipeline-0.8.3 vs lib/dirty_pipeline/event.rb in dirty_pipeline-0.9.0

- old
+ new

@@ -21,10 +21,19 @@ "args" => args, } ) end + def dup + self.class.new( + data: data.merge( + "uuid" => SecureRandom.uuid, + "status" => NEW, + ) + ) + end + attr_reader :id, :tx_id, :error, :data def initialize(options = {}, data: nil, error: nil) unless options.empty? options_hash = options.to_h data ||= options_hash["data"] @@ -52,10 +61,26 @@ def to_h {data: @data, error: @error} end + def source + data["source"] + end + + def source=(value) + data["source"] = value + end + + def destination + data["destination"] + end + + def destination=(value) + data["destination"] = value + end + %w(args transition cache destination changes).each do |method_name| define_method("#{method_name}") { @data[method_name] } end %w(new start retry failure success abort).each do |method_name| @@ -88,12 +113,11 @@ def assign_changes(changes) @data["changes"] = changes end - def complete(destination) + def complete @data.merge!( - "destination" => destination, "updated_at" => Time.now.utc.iso8601, "status" => SUCCESS, ) end end