Module: ArelOperators::Operators

Defined in:
lib/arel_operators/operators.rb

Instance Method Summary collapse

Instance Method Details

#-(other) ⇒ Object



13
14
15
# File 'lib/arel_operators/operators.rb', line 13

def -(other)
  self.and(-other)
end

#-@Object



17
18
19
# File 'lib/arel_operators/operators.rb', line 17

def -@
  build_arel_predicate(Arel::Predicates::Not, self)
end

#and(other) ⇒ Object



9
10
11
# File 'lib/arel_operators/operators.rb', line 9

def and(other)
  build_arel_predicate(Arel::Predicates::And, self, other)
end

#or(other) ⇒ Object Also known as: |, +



3
4
5
# File 'lib/arel_operators/operators.rb', line 3

def or(other)
  build_arel_predicate(Arel::Predicates::Or, self, other)
end

#where(obj, *args) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/arel_operators/operators.rb', line 21

def where(obj, *args)
  return super unless obj.respond_to?(:build_where)
  relation = obj.select(:id)
  other = clone.tap do |c|
    cond = build_where(Arel::Predicates::In.new(relation.primary_key, relation.arel))
    c.where_values = Array.wrap(cond)
  end
  self.and(other)
end