class Hyperwallet::HyperwalletObject

Public Class Methods

attributes() click to toggle source
# File lib/hyperwallet/hyperwallet_object.rb, line 24
def self.attributes
  []
end
construct_from(values) click to toggle source
# File lib/hyperwallet/hyperwallet_object.rb, line 32
def self.construct_from(values)
  object = self.new(values)
end
convert_to_hyperwallet_object(resp, type = nil, relation = nil) click to toggle source
# File lib/hyperwallet/hyperwallet_object.rb, line 12
def self.convert_to_hyperwallet_object(resp, type = nil, relation = nil)
  case resp
  when Array
    resp.map { |r| convert_to_hyperwallet_object(r, type, relation) }
  when Hash
    object_class = (relation.nil? ? type : type.relations[relation]) || HyperwalletObject
    object_class.construct_from(resp)
  else
    resp
  end
end
new(values) click to toggle source
# File lib/hyperwallet/hyperwallet_object.rb, line 4
def initialize(values)
  @values = {}
  (self.class.attributes + values.keys).each do |k|
    attr = Util.symbolize_attribute(k)
    @values[attr] = HyperwalletObject.convert_to_hyperwallet_object(values[k], self.class, attr)
  end
end
relations() click to toggle source
# File lib/hyperwallet/hyperwallet_object.rb, line 28
def self.relations
  {}
end

Public Instance Methods

method_missing(name, *args) click to toggle source
Calls superclass method
# File lib/hyperwallet/hyperwallet_object.rb, line 36
def method_missing(name, *args)
  if @values.has_key?(name)
    @values[name]
  else
    super
  end
end