Class: PayPal::SDK::Subscriptions::ErrorHash

Inherits:
Core::Util::OrderedHash
  • Object
show all
Defined in:
lib/paypal-sdk/subscriptions/error_hash.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/paypal-sdk/subscriptions/error_hash.rb', line 29

def method_missing(name, *args)
  if keys.include?(name) or keys.include?(name.to_s)
    self[name]
  else
    super
  end
end

Class Method Details

.convert(hash) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/paypal-sdk/subscriptions/error_hash.rb', line 5

def self.convert(hash)
  error_hash = new
  hash.each{|key, value|
    error_hash[key] = value
  }
  error_hash
end

Instance Method Details

#[](name) ⇒ Object



25
26
27
# File 'lib/paypal-sdk/subscriptions/error_hash.rb', line 25

def [](name)
  super(name.to_s) || super(name.to_sym)
end

#[]=(key, value) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/paypal-sdk/subscriptions/error_hash.rb', line 13

def []=(key, value)
  value =
    if value.is_a? Hash
      ErrorHash.convert(value)
    elsif value.is_a? Array and value[0].is_a? Hash
      value.map{|array_value| ErrorHash.convert(array_value) }
    else
      value
    end
  super(key, value)
end