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
490 491 492 493 |
# File 'lib/active_rdf/objectmanager/resource.rb', line 490 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
495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'lib/active_rdf/objectmanager/resource.rb', line 495 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.
485 486 487 |
# File 'lib/active_rdf/objectmanager/resource.rb', line 485 def value @value end |