Class: ApiResource::Finders::AbstractFinder
- Inherits:
-
Object
- Object
- ApiResource::Finders::AbstractFinder
- Defined in:
- lib/api_resource/finders/abstract_finder.rb
Direct Known Subclasses
MultiObjectAssociationFinder, ResourceFinder, SingleFinder, SingleObjectAssociationFinder
Instance Attribute Summary collapse
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#found ⇒ Object
readonly
Returns the value of attribute found.
-
#internal_object ⇒ Object
readonly
Returns the value of attribute internal_object.
-
#klass ⇒ Object
Returns the value of attribute klass.
Instance Method Summary collapse
- #all(*args) ⇒ Object
-
#initialize(klass, condition) ⇒ AbstractFinder
constructor
A new instance of AbstractFinder.
- #load ⇒ Object
-
#method_missing(method, *args, &block) ⇒ Object
proxy unknown methods to the internal_object.
Constructor Details
#initialize(klass, condition) ⇒ AbstractFinder
Returns a new instance of AbstractFinder.
14 15 16 17 18 19 20 |
# File 'lib/api_resource/finders/abstract_finder.rb', line 14 def initialize(klass, condition) @klass = klass @condition = condition @found = false @klass.load_resource_definition end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
proxy unknown methods to the internal_object
44 45 46 |
# File 'lib/api_resource/finders/abstract_finder.rb', line 44 def method_missing(method, *args, &block) self.internal_object.send(method, *args, &block) end |
Instance Attribute Details
#condition ⇒ Object
Returns the value of attribute condition.
8 9 10 |
# File 'lib/api_resource/finders/abstract_finder.rb', line 8 def condition @condition end |
#found ⇒ Object (readonly)
Returns the value of attribute found.
9 10 11 |
# File 'lib/api_resource/finders/abstract_finder.rb', line 9 def found @found end |
#internal_object ⇒ Object (readonly)
Returns the value of attribute internal_object.
9 10 11 |
# File 'lib/api_resource/finders/abstract_finder.rb', line 9 def internal_object @internal_object end |
#klass ⇒ Object
Returns the value of attribute klass.
8 9 10 |
# File 'lib/api_resource/finders/abstract_finder.rb', line 8 def klass @klass end |
Instance Method Details
#all(*args) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/api_resource/finders/abstract_finder.rb', line 35 def all(*args) if args.blank? self.internal_object else self.klass.send(:all, *args) end end |
#load ⇒ Object
22 23 24 |
# File 'lib/api_resource/finders/abstract_finder.rb', line 22 def load raise NotImplementedError("Must be defined in a subclass") end |