Module: Card::Query::Conjunctions

Included in:
Card::Query
Defined in:
lib/card/query/conjunctions.rb

Instance Method Summary collapse

Instance Method Details

#all(val) ⇒ Object Also known as: and



4
5
6
# File 'lib/card/query/conjunctions.rb', line 4

def all val
  conjoin val, :and
end

#any(val) ⇒ Object Also known as: or, in



9
10
11
# File 'lib/card/query/conjunctions.rb', line 9

def any val
  conjoin val, :or
end

#conjoin(val, conj) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/card/query/conjunctions.rb', line 15

def conjoin val, conj
  sq = subquery unjoined: true, conj: conj
  unless val.is_a? Array
    val = clause_to_hash(val).map { |key, value| { key => value } }
  end
  val.each do |val_item|
    sq.interpret val_item
  end
end

#conjunction(val) ⇒ Object



30
31
32
33
# File 'lib/card/query/conjunctions.rb', line 30

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

#not(val) ⇒ Object



25
26
27
28
# File 'lib/card/query/conjunctions.rb', line 25

def not val
  notjoin = join_cards val, conditions_on_join: true, side: "LEFT"
  add_condition "#{notjoin.table_alias}.id is null"
end