Class: ApRubySdk::BaseModel
- Inherits:
-
Object
- Object
- ApRubySdk::BaseModel
- Defined in:
- lib/ap_ruby_sdk/base_model.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#created ⇒ Object
Returns the value of attribute created.
-
#id ⇒ Object
Returns the value of attribute id.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#updated ⇒ Object
Returns the value of attribute updated.
Instance Method Summary collapse
- #attributes=(attributes) ⇒ Object
-
#initialize(attributes = {}) ⇒ BaseModel
constructor
A new instance of BaseModel.
- #to_json ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ BaseModel
Returns a new instance of BaseModel.
8 9 10 |
# File 'lib/ap_ruby_sdk/base_model.rb', line 8 def initialize(attributes={}) self.attributes = attributes end |
Instance Attribute Details
#created ⇒ Object
Returns the value of attribute created.
3 4 5 |
# File 'lib/ap_ruby_sdk/base_model.rb', line 3 def created @created end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/ap_ruby_sdk/base_model.rb', line 3 def id @id end |
#mode ⇒ Object
Returns the value of attribute mode.
3 4 5 |
# File 'lib/ap_ruby_sdk/base_model.rb', line 3 def mode @mode end |
#updated ⇒ Object
Returns the value of attribute updated.
3 4 5 |
# File 'lib/ap_ruby_sdk/base_model.rb', line 3 def updated @updated end |
Instance Method Details
#attributes=(attributes) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ap_ruby_sdk/base_model.rb', line 12 def attributes=(attributes) if attributes.respond_to?(:each) attributes.each do |key, value| writer = (key == 'type' ? 'kind=' : "#{key}=") if respond_to?(writer) send(writer, value) end end else attributes end end |
#to_json ⇒ Object
25 26 27 28 29 |
# File 'lib/ap_ruby_sdk/base_model.rb', line 25 def to_json hash = {} instance_variables.each { |var| hash[var.to_s.delete("@")] = instance_variable_get(var) } hash.to_json end |