Class: Velocity::Instance::APIModel
- Inherits:
-
Object
- Object
- Velocity::Instance::APIModel
- Defined in:
- lib/acceleration/velocity.rb
Overview
The APIModel is a very simple interface for building more complex API function models. It shouldn’t ever be instantiated itself.
TODO: refactor some of this method into something includable
Direct Known Subclasses
Alert, CollectionBroker, Dictionary, Query, Reports, Repository, Scheduler, SearchCollection, SearchCollection::Annotation, SearchCollection::CollectionService, SearchService, SourceTest
Instance Attribute Summary collapse
-
#instance ⇒ Object
A handle on the instance.
Instance Method Summary collapse
-
#initialize(instance) ⇒ APIModel
constructor
Create a new APIModel instance.
-
#method_missing(function, *args) ⇒ Object
This magical method enables a direct pass-through of methods if no special logic is required to handle the response.
-
#resolve(operation) ⇒ Object
Build the API function name based off the prefix and the desired operation.
- #respond_to_missing?(_function, _include_private = false) ⇒ Boolean
Constructor Details
#initialize(instance) ⇒ APIModel
Create a new APIModel instance
257 258 259 |
# File 'lib/acceleration/velocity.rb', line 257 def initialize(instance) @instance = instance end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(function, *args) ⇒ Object
This magical method enables a direct pass-through of methods if no special logic is required to handle the response.
282 283 284 285 286 |
# File 'lib/acceleration/velocity.rb', line 282 def method_missing(function, *args) instance.call resolve(function), args rescue super end |
Instance Attribute Details
#instance ⇒ Object
A handle on the instance
253 254 255 |
# File 'lib/acceleration/velocity.rb', line 253 def instance @instance end |
Instance Method Details
#resolve(operation) ⇒ Object
Build the API function name based off the prefix and the desired operation.
265 266 267 |
# File 'lib/acceleration/velocity.rb', line 265 def resolve(operation) [prefix, operation.dasherize].join '-' end |
#respond_to_missing?(_function, _include_private = false) ⇒ Boolean
288 289 290 |
# File 'lib/acceleration/velocity.rb', line 288 def respond_to_missing?(_function, _include_private = false) true end |