class ActiveMerchant::Billing::MultiResponse

Attributes

primary_response[R]
responses[R]

Public Class Methods

new(use_first_response = false) click to toggle source
# File lib/active_merchant/billing/response.rb, line 49
def initialize(use_first_response = false)
  @responses = []
  @use_first_response = use_first_response
  @primary_response = nil
end
run(use_first_response = false, &block) click to toggle source
# File lib/active_merchant/billing/response.rb, line 43
def self.run(use_first_response = false, &block)
  new(use_first_response).tap(&block)
end

Public Instance Methods

<<(response) click to toggle source
# File lib/active_merchant/billing/response.rb, line 70
def <<(response)
  if response.is_a?(MultiResponse)
    response.responses.each{|r| @responses << r}
  else
    @responses << response
  end
end
process(ignore_result=false) { || ... } click to toggle source
# File lib/active_merchant/billing/response.rb, line 55
def process(ignore_result=false)
  return unless success?

  response = yield
  self << response

  unless ignore_result
    if(@use_first_response && response.success?)
      @primary_response ||= response
    else
      @primary_response = response
    end
  end
end
success?() click to toggle source
# File lib/active_merchant/billing/response.rb, line 78
def success?
  (primary_response ? primary_response.success? : true)
end