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
432 433 434 435 |
# File 'lib/active_rdf/objectmanager/resource.rb', line 432 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
437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'lib/active_rdf/objectmanager/resource.rb', line 437 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.
427 428 429 |
# File 'lib/active_rdf/objectmanager/resource.rb', line 427 def value @value end |