Class: SecupayRuby::DataObjects::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/secupay_ruby/data_objects/base.rb

Direct Known Subclasses

PayoutAccount, User

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Base

Returns a new instance of Base.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/secupay_ruby/data_objects/base.rb', line 15

def initialize(attributes);
  class << self
    self
  end.class_eval do
    attr_accessor(*(self::API_FIELDS.keys))
  end

  api_fields.keys.each do |key|
    value = attributes[key]

    raise_attribute_missing_error(key) if value.nil?

    self.send("#{key}=", value)
  end
end

Instance Method Details

#to_api_fieldsObject



8
9
10
11
12
13
# File 'lib/secupay_ruby/data_objects/base.rb', line 8

def to_api_fields
  api_fields.keys.inject({}) do |hash, key|
    hash[api_fields[key]] = self.send(key)
    hash
  end
end