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
-
#initialize(api, model, actions) ⇒ ResourceModelProxy
constructor
A new instance of ResourceModelProxy.
- #is_a_proxied_model? ⇒ Boolean
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
Methods included from Actions
Methods included from FinderMethods
#all, extended, #find, included
Constructor Details
#initialize(api, model, actions) ⇒ ResourceModelProxy
16 17 18 19 |
# File 'lib/sequencescape-api/resource_model_proxy.rb', line 16 def initialize(api, model, actions) @api, @model, @actions = api, model, OpenStruct.new(actions) @model.send(:initialize_class_actions, self) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (protected)
33 34 35 |
# File 'lib/sequencescape-api/resource_model_proxy.rb', line 33 def method_missing(name, *args, &block) model.send(name, api, *args, &block) end |
Instance Method Details
#is_a_proxied_model? ⇒ Boolean
38 39 40 |
# File 'lib/sequencescape-api/resource_model_proxy.rb', line 38 def is_a_proxied_model? true end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
29 30 31 |
# File 'lib/sequencescape-api/resource_model_proxy.rb', line 29 def respond_to_missing?(name, include_private = false) super or model.respond_to?(name, include_private) end |