Class: Securetrading::BaseModel
- Inherits:
-
Object
- Object
- Securetrading::BaseModel
- Defined in:
- lib/securetrading/base_model.rb
Direct Known Subclasses
Amount, Billing, Customer, Dcc, Merchant, Name, Operation, Payment, Record, Response, ResponseError, Security, Settlement
Instance Attribute Summary collapse
-
#attributes_hash ⇒ Object
readonly
Returns the value of attribute attributes_hash.
Instance Method Summary collapse
-
#initialize(attrs_hash = {}) ⇒ BaseModel
constructor
A new instance of BaseModel.
- #ox_xml ⇒ Object
Constructor Details
#initialize(attrs_hash = {}) ⇒ BaseModel
Returns a new instance of BaseModel.
5 6 7 8 |
# File 'lib/securetrading/base_model.rb', line 5 def initialize(attrs_hash = {}) @attributes_hash = attrs_hash.presence && attrs_hash.transform_keys! { |k| k.to_s.tr('__', '') } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object (private)
31 32 33 34 |
# File 'lib/securetrading/base_model.rb', line 31 def method_missing(m, *args, &block) return super unless attributes_hash.key?(m.to_s) determine_value(m.to_s) end |
Instance Attribute Details
#attributes_hash ⇒ Object (readonly)
Returns the value of attribute attributes_hash.
3 4 5 |
# File 'lib/securetrading/base_model.rb', line 3 def attributes_hash @attributes_hash end |
Instance Method Details
#ox_xml ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/securetrading/base_model.rb', line 10 def ox_xml ox = ox_from_values sub_classes.each do |sub_class_name| next unless attributes_hash.key?(sub_class_name) ox << send(sub_class_name).ox_xml end ox end |