Method: MoneyKit::Balances#initialize

Defined in:
lib/moneykit/models/balances.rb

#initialize(attributes = {}) ⇒ Balances

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/moneykit/models/balances.rb', line 92

def initialize(attributes = {})
  unless attributes.is_a?(Hash)
    raise ArgumentError, 'The input argument (attributes) must be a hash in `MoneyKit::Balances` initialize method'
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) do |(k, v), h|
    unless self.class.attribute_map.key?(k.to_sym)
      raise ArgumentError,
            "`#{k}` is not a valid attribute in `MoneyKit::Balances`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end

    h[k.to_sym] = v
  end

  self.currency = attributes[:currency] if attributes.key?(:currency)

  self.available = attributes[:available] if attributes.key?(:available)

  self.current = attributes[:current] if attributes.key?(:current)

  return unless attributes.key?(:limit)

  self.limit = attributes[:limit]
end