Sha256: f568d08fff05f7997731119104fb68560ce1e74fc36627ba68fbbe0adf70719c

Contents?: true

Size: 916 Bytes

Versions: 17

Compression:

Stored size: 916 Bytes

Contents

module Ddr::Index
  class Filter

    class << self
      delegate :where, :raw, :before_days, :before, :present, :absent, to: :new
    end

    attr_accessor :clauses

    def initialize
      @clauses = [ ]
    end

    def where(conditions)
      clauses = conditions.map do |field, value|
        if value.respond_to?(:each)
          QueryClause.or_values(field, *value)
        else
          QueryClause.term(field, value)
        end
      end
      raw *clauses
    end

    # Adds clause (String) w/o escaping
    def raw(*clauses)
      self.clauses += clauses
      self
    end

    def present(field)
      raw QueryClause.present(field)
    end

    def absent(field)
      raw QueryClause.absent(field)
    end

    def before(field, date_time)
      raw QueryClause.before(field, date_time)
    end

    def before_days(field, days)
      raw QueryClause.before_days(field, days)
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ddr-models-3.0.0.beta.3 lib/ddr/index/filter.rb
ddr-models-3.0.0.beta.2 lib/ddr/index/filter.rb
ddr-models-2.3.2 lib/ddr/index/filter.rb
ddr-models-3.0.0.beta.1 lib/ddr/index/filter.rb
ddr-models-2.3.1 lib/ddr/index/filter.rb
ddr-models-3.0.0.alpha.4 lib/ddr/index/filter.rb
ddr-models-3.0.0.alpha.3 lib/ddr/index/filter.rb
ddr-models-2.3.0 lib/ddr/index/filter.rb
ddr-models-3.0.0.alpha.2 lib/ddr/index/filter.rb
ddr-models-3.0.0.alpha.1 lib/ddr/index/filter.rb
ddr-models-2.2.0 lib/ddr/index/filter.rb
ddr-models-2.1.3 lib/ddr/index/filter.rb
ddr-models-2.1.2 lib/ddr/index/filter.rb
ddr-models-2.1.1 lib/ddr/index/filter.rb
ddr-models-2.1.0 lib/ddr/index/filter.rb
ddr-models-2.1.0.rc2 lib/ddr/index/filter.rb
ddr-models-2.1.0.rc1 lib/ddr/index/filter.rb