Sha256: d20c56917c8e07768d6e49b0d307c041a0dc4cc36b423e359ae1b3f16cd45269
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
module RecordFilter module DSL class Conjunction attr_reader :type, :steps DEFAULT_VALUE = Object.new def initialize(type=:all_of) @type, @steps = type, [] end def add_restriction(column, value, negated) @steps << (restriction = Restriction.new(column, negated)) if value == DEFAULT_VALUE return restriction elsif value.nil? restriction.is_null else restriction.equal_to(value) end nil end def add_conjunction(type, &block) dsl = ConjunctionDSL.new(Conjunction.new(type)) dsl.instance_eval(&block) if block @steps << dsl.conjunction end def add_join(association, &block) dsl = ConjunctionDSL.new dsl.instance_eval(&block) if block @steps << (join = Join.new(association, dsl.conjunction)) join end def add_limit(limit, offset) @steps << Limit.new(limit, offset) end def add_order(column, direction) @steps << Order.new(column, direction) end end end end
Version data entries
3 entries across 3 versions & 2 rubygems