Class: DynamicFinderProxy
- Inherits:
-
Object
- Object
- DynamicFinderProxy
- Defined in:
- lib/active_rdf/objectmanager/resource.rb
Overview
proxy to manage find_by_ invocations
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(find_string, where, *args) ⇒ DynamicFinderProxy
constructor
construct proxy from find_by text foaf::name.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(find_string, where, *args) ⇒ DynamicFinderProxy
construct proxy from find_by text foaf::name
425 426 427 428 |
# File 'lib/active_rdf/objectmanager/resource.rb', line 425 def initialize(find_string, where, *args) @where = where || [] parse_attributes(find_string, *args) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
# File 'lib/active_rdf/objectmanager/resource.rb', line 430 def method_missing(method, *args) # we store the ns:name for later (we need to wait until we have the # arguments before actually constructing the where clause): now we just # store that a where clause should appear about foaf:name # if this method is called name_and_foaf::age we add ourself to the query # otherwise, the query is built: we execute it and return the results if method.to_s.include?('_and_') parse_attributes(method.to_s, *args) else @where << Namespace.lookup(@ns, method.to_s) query(*args) end end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
420 421 422 |
# File 'lib/active_rdf/objectmanager/resource.rb', line 420 def value @value end |