Sha256: 4622e1169f93dc11b056350250ef888ac91767c875e4ca6aa6b4672a548a2dd8

Contents?: true

Size: 1012 Bytes

Versions: 5

Compression:

Stored size: 1012 Bytes

Contents

module RecordFilter
  module DSL
    class ConjunctionDSL

      attr_reader :conjunction

      def initialize(conjunction=Conjunction.new(:all_of))
        @conjunction = conjunction
      end

      # restriction
      def with(column, value=Conjunction::DEFAULT_VALUE)
        return @conjunction.add_restriction(column, value, false) # using return just to make it explicit
      end

      # restriction
      def without(column, value=Conjunction::DEFAULT_VALUE)
        return @conjunction.add_restriction(column, value, true) # using return just to make it explicit
      end

      # conjunction
      def any_of(&block)
        @conjunction.add_conjunction(:any_of, &block)
        nil
      end

      # conjunction
      def all_of(&block)
        @conjunction.add_conjunction(:all_of, &block)
        nil
      end

      # join
      def having(association, &block)
        join = @conjunction.add_join(association, &block)
        ConjunctionDSL.new(join.conjunction)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
aub-record_filter-0.1.0 lib/record_filter/dsl/conjunction_dsl.rb
aub-record_filter-0.1.1 lib/record_filter/dsl/conjunction_dsl.rb
aub-record_filter-0.1.2 lib/record_filter/dsl/conjunction_dsl.rb
outoftime-record_filter-0.1.0 lib/record_filter/dsl/conjunction_dsl.rb
outoftime-record_filter-0.1.1 lib/record_filter/dsl/conjunction_dsl.rb