Module: Tripod::CriteriaExecution
- Extended by:
- ActiveSupport::Concern
- Included in:
- Criteria
- Defined in:
- lib/tripod/criteria/execution.rb
Overview
this module provides execution methods to a criteria object
Instance Method Summary collapse
-
#count ⇒ Object
Return how many records the current criteria would return.
-
#first ⇒ Object
Execute the query and return the first result as a hydrated resource.
-
#resources ⇒ Object
Execute the query and return a
ResourceCollectionof all hydrated resourcesResourceCollectionis anEnumerable, Array-like object.
Instance Method Details
#count ⇒ Object
Return how many records the current criteria would return
26 27 28 29 30 31 |
# File 'lib/tripod/criteria/execution.rb', line 26 def count sq = Tripod::SparqlQuery.new(build_select_query) count_sparql = sq.as_count_query_str result = Tripod::SparqlClient::Query.select(count_sparql) result[0][".1"]["value"].to_i end |
#first ⇒ Object
Execute the query and return the first result as a hydrated resource
19 20 21 22 23 |
# File 'lib/tripod/criteria/execution.rb', line 19 def first sq = Tripod::SparqlQuery.new(build_select_query) first_sparql = sq.as_first_query_str resources_from_sparql(first_sparql).first end |
#resources ⇒ Object
Execute the query and return a ResourceCollection of all hydrated resources ResourceCollection is an Enumerable, Array-like object.
11 12 13 14 15 |
# File 'lib/tripod/criteria/execution.rb', line 11 def resources Tripod::ResourceCollection.new( resources_from_sparql(build_select_query) ) end |