Class: Fabricio::Model::AbstractModel
- Inherits:
-
Object
- Object
- Fabricio::Model::AbstractModel
- Defined in:
- lib/fabricio/models/abstract_model.rb
Overview
Defines a base class for all data models
Direct Known Subclasses
Instance Attribute Summary collapse
-
#json ⇒ Object
Plain data from the server.
Instance Method Summary collapse
-
#method_missing(*args) ⇒ Object
We use ‘method_missing` approach here to allow a user query any field from the original data structure sent by server.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
We use ‘method_missing` approach here to allow a user query any field from the original data structure sent by server.
9 10 11 12 13 14 |
# File 'lib/fabricio/models/abstract_model.rb', line 9 def method_missing(*args) method_name = args.first json_value = @json[method_name.to_s] return json_value if json_value raise NoMethodError.new("There's no method called #{args.first} here -- please try again.", args.first) end |
Instance Attribute Details
#json ⇒ Object
Plain data from the server
6 7 8 |
# File 'lib/fabricio/models/abstract_model.rb', line 6 def json @json end |