Module: Sequel::DatasetQuery
- Defined in:
- lib/sequel/extensions/query.rb
Instance Method Summary collapse
-
#query(&block) ⇒ Object
Translates a query block into a dataset.
Instance Method Details
#query(&block) ⇒ Object
Translates a query block into a dataset. Query blocks are an alternative to Sequel’s usual method chaining, by using instance_eval with a proxy object:
dataset = DB[:items].query do
select :x, :y, :z
filter{(x > 1) & (y > 2)}
reverse :z
end
Which is the same as:
dataset = DB[:items].select(:x, :y, :z).filter{(x > 1) & (y > 2)}.reverse(:z)
50 51 52 53 54 |
# File 'lib/sequel/extensions/query.rb', line 50 def query(&block) query = Dataset::Query.new(self) query.instance_eval(&block) query.dataset end |