Sha256: 6f03c9a297d8ee5b857e8b30957b6d832c3b2e3ebb005876526afe7db1ef5a47

Contents?: true

Size: 1.01 KB

Versions: 13

Compression:

Stored size: 1.01 KB

Contents

class Card
  module Query
    class CardQuery
      # conjoining conditions
      module Conjunctions
        def all val
          conjoin val, :and
        end
        alias_method :and, :all

        def any val
          conjoin val, :or
        end
        alias_method :or, :any
        alias_method :in, :any

        def not val
          tie :card, val, { id: :id }, negate: true
        end

        def current_conjunction
          @mods[:conj].blank? ? :and : @mods[:conj]
        end

        private

        def conjunction val
          return unless [String, Symbol].member? val.class
          CONJUNCTIONS[val.to_sym]
        end

        def conjoin val, conj
          subquery = subquery fasten: :direct, conj: conj
          conjoinable_val(val).each do |val_item|
            subquery.interpret val_item
          end
        end

        def conjoinable_val val
          return val if val.is_a? Array
          clause_to_hash(val).map { |key, value| { key => value } }
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
card-1.96.8 lib/card/query/card_query/conjunctions.rb
card-1.96.7 lib/card/query/card_query/conjunctions.rb
card-1.96.6 lib/card/query/card_query/conjunctions.rb
card-1.96.5 lib/card/query/card_query/conjunctions.rb
card-1.96.4 lib/card/query/card_query/conjunctions.rb
card-1.96.3 lib/card/query/card_query/conjunctions.rb
card-1.96.2 lib/card/query/card_query/conjunctions.rb
card-1.96.1 lib/card/query/card_query/conjunctions.rb
card-1.96.0 lib/card/query/card_query/conjunctions.rb
card-1.95.3 lib/card/query/card_query/conjunctions.rb
card-1.95.2 lib/card/query/card_query/conjunctions.rb
card-1.95.1 lib/card/query/card_query/conjunctions.rb
card-1.95.0 lib/card/query/card_query/conjunctions.rb