Sha256: 91a19edd362cf058e39b6722ae085364e3b7b18a14eff09f97335fd53261ffa7
Contents?: true
Size: 833 Bytes
Versions: 4
Compression:
Stored size: 833 Bytes
Contents
module RecordFilter class Query def initialize(clazz, dsl_conjunction) @table = RecordFilter::Table.new(clazz) @conjunction = RecordFilter::Conjunctions::Base.create_from(dsl_conjunction, @table) end def to_find_params params = { :conditions => @conjunction.to_conditions } joins = @table.all_joins params[:joins] = joins.map { |join| join.to_sql } * ' ' unless joins.empty? orders = @table.orders params[:order] = orders.map { |order| order.to_sql } * ', ' unless orders.empty? group_bys = @table.group_bys params[:group] = group_bys.map { |group_by| group_by.to_sql } * ', ' unless group_bys.empty? params[:limit] = @conjunction.limit if @conjunction.limit params[:offset] = @conjunction.offset if @conjunction.offset params end end end
Version data entries
4 entries across 4 versions & 2 rubygems