class Orchestrated::MessageDelivery

Attributes

args[RW]
method_name[RW]
orchestrated[RW]
orchestration_id[RW]

Public Class Methods

new(orchestrated, method_name, args, orchestration_id) click to toggle source
# File lib/orchestrated/message_delivery.rb, line 5
def initialize(orchestrated, method_name, args, orchestration_id)
  raise ArgumentError.new('all arguments to MessageDelivery constructor are required') unless
    orchestrated and method_name and args and orchestration_id
  self.orchestrated = orchestrated
  self.method_name  = method_name
  self.args         = args
  self.orchestration_id = orchestration_id
end

Public Instance Methods

failure() click to toggle source

delayed_job hands us this message after max_attempts are exhausted

# File lib/orchestrated/message_delivery.rb, line 25
def failure
  orchestration = Orchestration.find(self.orchestration_id)
  orchestration.message_delivery_failed
end
perform() click to toggle source
# File lib/orchestrated/message_delivery.rb, line 14
def perform
  orchestration = Orchestration.find(self.orchestration_id)

  orchestrated.orchestration = orchestration
  orchestrated.send(method_name, *args)
  orchestrated.orchestration = nil

  orchestration.message_delivery_succeeded
end