Sha256: ec011b71b159557b0f4dc2e5b802d89972f39e2837e3504e52bc6eb97ed88d99

Contents?: true

Size: 1.02 KB

Versions: 23

Compression:

Stored size: 1.02 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

23 entries across 23 versions & 1 rubygems

Version Path
card-1.108.1 lib/card/query/card_query/conjunctions.rb
card-1.108.0 lib/card/query/card_query/conjunctions.rb
card-1.107.0 lib/card/query/card_query/conjunctions.rb
card-1.106.0 lib/card/query/card_query/conjunctions.rb
card-1.105.6 lib/card/query/card_query/conjunctions.rb
card-1.105.5 lib/card/query/card_query/conjunctions.rb
card-1.105.4 lib/card/query/card_query/conjunctions.rb
card-1.105.3 lib/card/query/card_query/conjunctions.rb
card-1.105.2.pre1 lib/card/query/card_query/conjunctions.rb
card-1.105.2 lib/card/query/card_query/conjunctions.rb
card-1.105.1 lib/card/query/card_query/conjunctions.rb
card-1.105.0 lib/card/query/card_query/conjunctions.rb
card-1.104.2 lib/card/query/card_query/conjunctions.rb
card-1.104.1 lib/card/query/card_query/conjunctions.rb
card-1.104.0 lib/card/query/card_query/conjunctions.rb
card-1.103.4 lib/card/query/card_query/conjunctions.rb
card-1.103.3 lib/card/query/card_query/conjunctions.rb
card-1.103.2 lib/card/query/card_query/conjunctions.rb
card-1.103.1 lib/card/query/card_query/conjunctions.rb
card-1.103.0 lib/card/query/card_query/conjunctions.rb