Class: ResourceFull::Query::ScopedParameter
Instance Attribute Summary collapse
Attributes inherited from Parameter
#name, #resource
Instance Method Summary
collapse
Methods inherited from Parameter
#allow_nil?, #applicable_to?, #fuzzy?, #to_xml
Constructor Details
#initialize(name, resource, opts = {}) ⇒ ScopedParameter
Returns a new instance of ScopedParameter.
184
185
186
187
|
# File 'lib/resource_full/query.rb', line 184
def initialize(name, resource, opts={})
super(name, resource, opts)
@scope = opts[:scope]
end
|
Instance Attribute Details
#scope ⇒ Object
Returns the value of attribute scope.
182
183
184
|
# File 'lib/resource_full/query.rb', line 182
def scope
@scope
end
|
Instance Method Details
#find(finder, request_params) ⇒ Object
193
194
195
196
197
198
199
200
201
202
203
|
# File 'lib/resource_full/query.rb', line 193
def find(finder, request_params)
return finder unless applicable_to?(request_params)
if proc_scoped?
finder.scoped scope.call(*param_values_for(request_params))
elsif hash_scoped?
finder.scoped scope
else
finder.send(scope, *param_values_for(request_params))
end
end
|
#hash_scoped? ⇒ Boolean
191
|
# File 'lib/resource_full/query.rb', line 191
def hash_scoped?; @scope.is_a?(Hash); end
|
#method_scoped? ⇒ Boolean
189
|
# File 'lib/resource_full/query.rb', line 189
def method_scoped?; @scope.is_a?(Symbol); end
|
#proc_scoped? ⇒ Boolean
190
|
# File 'lib/resource_full/query.rb', line 190
def proc_scoped?; @scope.is_a?(Proc); end
|
#subclass(new_resource) ⇒ Object
205
206
207
|
# File 'lib/resource_full/query.rb', line 205
def subclass(new_resource)
self.class.new @name, new_resource, :scope => @scope
end
|