Module: Arel::Attribute::Congruence

Included in:
Arel::Attribute
Defined in:
lib/arel/algebra/attributes/attribute.rb

Instance Method Summary collapse

Instance Method Details

#/(other) ⇒ Object



78
79
80
# File 'lib/arel/algebra/attributes/attribute.rb', line 78

def /(other)
  other ? (history & other.history).size : 0
end

#descends_from?(other) ⇒ Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/arel/algebra/attributes/attribute.rb', line 74

def descends_from?(other)
  history.include?(other)
end

#find_correlate_in(relation) ⇒ Object



70
71
72
# File 'lib/arel/algebra/attributes/attribute.rb', line 70

def find_correlate_in(relation)
  relation[self] || self
end

#historyObject



50
51
52
# File 'lib/arel/algebra/attributes/attribute.rb', line 50

def history
  @history ||= [self] + (ancestor ? ancestor.history : [])
end

#join?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/arel/algebra/attributes/attribute.rb', line 54

def join?
  relation.join?
end

#original_attributeObject



66
67
68
# File 'lib/arel/algebra/attributes/attribute.rb', line 66

def original_attribute
  @original_attribute ||= history.detect { |a| !a.join? }
end

#original_relationObject



62
63
64
# File 'lib/arel/algebra/attributes/attribute.rb', line 62

def original_relation
  @original_relation ||= original_attribute.relation
end

#rootObject



58
59
60
# File 'lib/arel/algebra/attributes/attribute.rb', line 58

def root
  history.last
end