Class: ActiveMerchant::Billing::MultiResponse
- Defined in:
- lib/active_merchant/billing/response.rb
Instance Attribute Summary collapse
-
#primary_response ⇒ Object
readonly
Returns the value of attribute primary_response.
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
Attributes inherited from Response
#authorization, #avs_result, #cvv_result, #message, #params, #test
Class Method Summary collapse
Instance Method Summary collapse
- #<<(response) ⇒ Object
-
#initialize(use_first_response = false) ⇒ MultiResponse
constructor
A new instance of MultiResponse.
- #process(ignore_result = false) ⇒ Object
- #success? ⇒ Boolean
Methods inherited from Response
Constructor Details
#initialize(use_first_response = false) ⇒ MultiResponse
Returns a new instance of MultiResponse.
48 49 50 51 52 |
# File 'lib/active_merchant/billing/response.rb', line 48 def initialize(use_first_response = false) @responses = [] @use_first_response = use_first_response @primary_response = nil end |
Instance Attribute Details
#primary_response ⇒ Object (readonly)
Returns the value of attribute primary_response.
46 47 48 |
# File 'lib/active_merchant/billing/response.rb', line 46 def primary_response @primary_response end |
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
46 47 48 |
# File 'lib/active_merchant/billing/response.rb', line 46 def responses @responses end |
Class Method Details
.run(use_first_response = false, &block) ⇒ Object
42 43 44 |
# File 'lib/active_merchant/billing/response.rb', line 42 def self.run(use_first_response = false, &block) new(use_first_response).tap(&block) end |
Instance Method Details
#<<(response) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/active_merchant/billing/response.rb', line 69 def <<(response) if response.is_a?(MultiResponse) response.responses.each{|r| @responses << r} else @responses << response end end |
#process(ignore_result = false) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/active_merchant/billing/response.rb', line 54 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? ⇒ Boolean
77 78 79 |
# File 'lib/active_merchant/billing/response.rb', line 77 def success? (primary_response ? primary_response.success? : true) end |