module Sequel::DatasetQuery

  1. lib/sequel/extensions/query.rb

Methods

Public Instance

  1. query

Public Instance methods

query(&block)

Translates a query block into a dataset. Query blocks are an alternative to Sequel’s usual method chaining, by using instance_exec with a proxy object:

dataset = DB[:items].query do
  select :x, :y, :z
  where{(x > 1) & (y > 2)}
  reverse :z
end

Which is the same as:

dataset = DB[:items].select(:x, :y, :z).where{(x > 1) & (y > 2)}.reverse(:z)
[show source]
   # File lib/sequel/extensions/query.rb
53 def query(&block)
54   query = Dataset::Query.new(self)
55   query.instance_exec(&block)
56   query.dataset
57 end