Class: Sequencescape::Api::ResourceModelProxy
- Inherits:
-
Object
- Object
- Sequencescape::Api::ResourceModelProxy
- Extended by:
- Actions
- Includes:
- FinderMethods
- Defined in:
- lib/sequencescape-api/resource_model_proxy.rb
Overview
Any interaction with the API isn't done directly through a model but through an instance of this class, that proxies the model and ensures that it uses the correct instance of Sequencescape::Api.
Instance Method Summary (collapse)
-
- (ResourceModelProxy) initialize(api, model, actions)
constructor
A new instance of ResourceModelProxy.
- - (Boolean) respond_to_missing?(name, include_private = false)
Methods included from Actions
has_create_action, has_update_action
Methods included from FinderMethods
#all, extended, #find, included
Constructor Details
- (ResourceModelProxy) initialize(api, model, actions)
A new instance of ResourceModelProxy
17 18 19 |
# File 'lib/sequencescape-api/resource_model_proxy.rb', line 17 def initialize(api, model, actions) @api, @model, @actions = api, model, OpenStruct.new(actions) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(name, *args, &block) (protected)
32 33 34 |
# File 'lib/sequencescape-api/resource_model_proxy.rb', line 32 def method_missing(name, *args, &block) model.send(name, api, *args, &block) end |
Instance Method Details
- (Boolean) respond_to_missing?(name, include_private = false)
28 29 30 |
# File 'lib/sequencescape-api/resource_model_proxy.rb', line 28 def respond_to_missing?(name, include_private = false) super or model.respond_to?(name, include_private) end |