Class: PayPalResponse

Inherits:
Hash
  • Object
show all
Defined in:
lib/ruby-paypal/paypal.rb

Overview

A container for the response from PayPal. Each call to PayPal returns a generic set of information as well as a specific set for the call. For more information please refer to PayPal NVP API Developer Guide and Reference.

To use retrieve information in the response, call the corresponding name of the object. For example, all responses from PayPal includes the field ACK. To get the data for this field:

if response.ack == 'Success' then
 # do your stuff
end

This is because this class uses a meta-programming trick with method_missing to redirect all known method calls to its internal hash data structure.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *a) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/ruby-paypal/paypal.rb', line 42

def method_missing(m,*a)
  if m.to_s.upcase =~ /=$/
    self[$`] = a[0]
  elsif a.empty?
    self[m.to_s.upcase]
  else
    raise NoMethodError, "#{m}"
  end
end