Class: SecupayRuby::DataObjects::Base
- Inherits:
-
Object
- Object
- SecupayRuby::DataObjects::Base
- Defined in:
- lib/secupay_ruby/data_objects/base.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Base
constructor
A new instance of Base.
- #to_api_fields ⇒ Object
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_fields ⇒ Object
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 |