Class: Relix::Query
- Inherits:
-
Object
- Object
- Relix::Query
- Defined in:
- lib/relix/query.rb
Defined Under Namespace
Classes: Clause
Instance Method Summary collapse
- #[](index_name) ⇒ Object
-
#initialize(model) ⇒ Query
constructor
A new instance of Query.
- #run ⇒ Object
Constructor Details
#initialize(model) ⇒ Query
Returns a new instance of Query.
3 4 5 6 |
# File 'lib/relix/query.rb', line 3 def initialize(model) @model = model @offset = 0 end |
Instance Method Details
#[](index_name) ⇒ Object
8 9 10 11 12 |
# File 'lib/relix/query.rb', line 8 def [](index_name) index = @model[index_name] raise MissingIndexError.new("No index declared for #{index_name}") unless index @clause = index.create_query_clause(@model.redis) end |
#run ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/relix/query.rb', line 14 def run if @clause @clause.lookup else @model.primary_key_index.lookup end end |