Sha256: 7830f8e21df3e367f49475548570a7a1c0b62e55b73bd5961c7bb0531a5a4d97
Contents?: true
Size: 1.12 KB
Versions: 19
Compression:
Stored size: 1.12 KB
Contents
module Ddr::Index class QueryBuilder def self.build builder = new yield builder builder.query end def initialize @q = nil @fields = [ ] @filters = [ ] @sort = [ ] @rows = nil end def query Query.new.tap do |qry| instance_variables.each do |var| qry.instance_variable_set(var, instance_variable_get(var)) end end end def id(pid) q QueryClause.id(pid) limit 1 end def filter(*fltrs) @filters.push *fltrs self end def fields(*flds) @fields.push *flds self end def limit(num) @rows = num self end def order_by(field, order) @sort << [field, order].join(" ") self end def asc(field) order_by field, "asc" end def desc(field) order_by field, "desc" end def q(q) @q = q self end protected def method_missing(name, *args, &block) if Filter.respond_to? name return filter Filter.send(name, *args, &block) end super end end end
Version data entries
19 entries across 19 versions & 1 rubygems