Class: Modulr::Resources::Base
- Inherits:
-
Object
- Object
- Modulr::Resources::Base
- Defined in:
- lib/modulr/resources/base.rb
Direct Known Subclasses
Accounts::Account, Accounts::Identifier, Customers::Customer, Notifications::Config, Notifications::Notification, Payments::Counterparty, Payments::Destination, Payments::Details::Incoming::General, Payments::Details::Incoming::Internal, Payments::Details::Outgoing::General, Payments::Payment, Transactions::Transaction
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response, attributes = {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(response, attributes = {}) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 14 15 |
# File 'lib/modulr/resources/base.rb', line 8 def initialize(response, attributes = {}) @response = response attributes.each do |key, value| m = "#{key}=".to_sym send(m, value) if respond_to?(m) end end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/modulr/resources/base.rb', line 6 def response @response end |
Class Method Details
.map(original_attribute, mapped_attributes = nil) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/modulr/resources/base.rb', line 17 def self.map(original_attribute, mapped_attributes = nil) class_eval { attr_writer original_attribute.to_sym } mapped_attributes ||= original_attribute mapped_attributes = [mapped_attributes].flatten mapped_attributes.each do |mapped_attribute| define_method(mapped_attribute) { instance_variable_get("@#{original_attribute}") } end end |