Class: Quickbooks::Payments::BasicModel
- Inherits:
-
Object
- Object
- Quickbooks::Payments::BasicModel
- Defined in:
- lib/quickbooks-payments/basic_model.rb
Overview
Basic JSON backed model
Direct Known Subclasses
Instance Attribute Summary collapse
-
#json ⇒ Object
Returns the value of attribute json.
Instance Method Summary collapse
-
#initialize(json = {}) ⇒ BasicModel
constructor
A new instance of BasicModel.
-
#to_json ⇒ Object
Getters.
Constructor Details
#initialize(json = {}) ⇒ BasicModel
Returns a new instance of BasicModel.
7 8 9 10 11 12 13 14 |
# File 'lib/quickbooks-payments/basic_model.rb', line 7 def initialize(json = {}) self.json = json json.each do |key, value| setter = "#{key}=" send(setter, value) if respond_to?(setter) end end |
Instance Attribute Details
#json ⇒ Object
Returns the value of attribute json.
5 6 7 |
# File 'lib/quickbooks-payments/basic_model.rb', line 5 def json @json end |
Instance Method Details
#to_json ⇒ Object
Getters
18 19 20 21 22 |
# File 'lib/quickbooks-payments/basic_model.rb', line 18 def to_json instance_variables.each_with_object({}) do |variable, sum| sum[variable[1..-1]] = instance_variable_get variable end.to_json end |