Class: ActiveRecord::Relation

Inherits:
Object
  • Object
show all
Defined in:
lib/active-record-ex/relation_extensions.rb

Direct Known Subclasses

ActiveRecordEx::ManyToMany::ModelArel

Instance Method Summary collapse

Instance Method Details

#disjunct(other) ⇒ Object



13
14
15
16
17
# File 'lib/active-record-ex/relation_extensions.rb', line 13

def disjunct(other)
  other_where = other.collapsed_where
  this_where = self.collapsed_where
  self.where_only(this_where.or(other_where))
end

#noneObject



9
10
11
# File 'lib/active-record-ex/relation_extensions.rb', line 9

def none
  self.where('1=0')
end

#relative_complement(other) ⇒ Object

If self and other are viewed as sets relative_complement represents everything that’s in other but NOT in self



22
23
24
25
26
# File 'lib/active-record-ex/relation_extensions.rb', line 22

def relative_complement(other)
  this_where = self.collapsed_where
  other_where = other.collapsed_where
  self.where_only(this_where.not.and(other_where))
end

#where_only(value) ⇒ Object



3
4
5
6
7
# File 'lib/active-record-ex/relation_extensions.rb', line 3

def where_only(value)
  relation = clone
  relation.where_values = build_where(value)
  relation
end