Class: Unleashed::BaseModel
- Inherits:
-
Object
- Object
- Unleashed::BaseModel
- Defined in:
- lib/unleashed/models/base_model.rb
Overview
Base model for all the other models to inherit from
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#initialize(client, attributes = {}) ⇒ BaseModel
constructor
A new instance of BaseModel.
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize(client, attributes = {}) ⇒ BaseModel
Returns a new instance of BaseModel.
6 7 8 9 |
# File 'lib/unleashed/models/base_model.rb', line 6 def initialize(client, attributes = {}) @client = client @attributes = stringify_keys(attributes) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/unleashed/models/base_model.rb', line 11 def method_missing(name, *args, &block) if @attributes.key?(name.to_s) @attributes[name.to_s] else super end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/unleashed/models/base_model.rb', line 4 def attributes @attributes end |