Class: Appfuel::Repository::Runner
- Inherits:
-
Object
- Object
- Appfuel::Repository::Runner
- Defined in:
- lib/appfuel/storage/repository/runner.rb
Instance Attribute Summary collapse
-
#criteria_class ⇒ Object
readonly
Returns the value of attribute criteria_class.
-
#repo_namespace ⇒ Object
readonly
Returns the value of attribute repo_namespace.
Instance Method Summary collapse
- #create_criteria(entity_key, opts = {}) ⇒ Object
- #exists?(entity_key, opts = {}) ⇒ Bool
-
#initialize(namespace, criteria_class) ⇒ Runner
constructor
The call relies on the fact that we can build a criteria find the correct repo and call the exists? interface on that repo.
- #query(criteria) ⇒ Object
Constructor Details
#initialize(namespace, criteria_class) ⇒ Runner
The call relies on the fact that we can build a criteria find the correct repo and call the exists? interface on that repo. The identity of any given repo requires its namespace + its class name.
15 16 17 18 |
# File 'lib/appfuel/storage/repository/runner.rb', line 15 def initialize(namespace, criteria_class) @repo_namespace = namespace @criteria_class = criteria_class end |
Instance Attribute Details
#criteria_class ⇒ Object (readonly)
Returns the value of attribute criteria_class.
6 7 8 |
# File 'lib/appfuel/storage/repository/runner.rb', line 6 def criteria_class @criteria_class end |
#repo_namespace ⇒ Object (readonly)
Returns the value of attribute repo_namespace.
6 7 8 |
# File 'lib/appfuel/storage/repository/runner.rb', line 6 def repo_namespace @repo_namespace end |
Instance Method Details
#create_criteria(entity_key, opts = {}) ⇒ Object
20 21 22 |
# File 'lib/appfuel/storage/repository/runner.rb', line 20 def create_criteria(entity_key, opts = {}) criteria_class.new(entity_key, opts) end |
#exists?(entity_key, opts = {}) ⇒ Bool
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/appfuel/storage/repository/runner.rb', line 33 def exists?(entity_key, opts = {}) fail "opts must be a hash" unless opts.is_a?(Hash) criteria_opts = {} if opts.key?(:repo) criteria_opts[:repo] = opts.delete(:repo) end fail "opts hash must have one attr => value pair" if opts.empty? property, value = opts.first criteria = create_criteria(entity_key, criteria_opts) criteria.exists(property, value) load_repo(criteria).exists?(criteria) end |
#query(criteria) ⇒ Object
24 25 26 |
# File 'lib/appfuel/storage/repository/runner.rb', line 24 def query(criteria) load_repo(criteria).query(criteria) end |