Class: Cathode::Query
- Inherits:
-
Object
- Object
- Cathode::Query
- Defined in:
- lib/cathode/query.rb
Overview
Holds the Cathode Query DSL interface.
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#initialize(model, query) ⇒ Query
constructor
Initialize and parse a query.
Constructor Details
#initialize(model, query) ⇒ Query
Initialize and parse a query.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cathode/query.rb', line 9 def initialize(model, query) clauses = query.split ',' results = model clauses.each do |clause| words = clause.split results = case words.first when 'where' results.where(words.drop(1).join ' ') else results.where(words.join ' ') end end @results = results end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
4 5 6 |
# File 'lib/cathode/query.rb', line 4 def results @results end |