Module: Arel::Attribute::Transformations

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



27
28
29
# File 'lib/arel/algebra/attributes/attribute.rb', line 27

def self.included(klass)
  klass.send :alias_method, :eql?, :==
end

Instance Method Details

#as(aliaz = nil) ⇒ Object



35
36
37
# File 'lib/arel/algebra/attributes/attribute.rb', line 35

def as(aliaz = nil)
  Attribute.new(relation, name, :alias => aliaz, :ancestor => self)
end

#bind(new_relation) ⇒ Object



39
40
41
# File 'lib/arel/algebra/attributes/attribute.rb', line 39

def bind(new_relation)
  relation == new_relation ? self : Attribute.new(new_relation, name, :alias => @alias, :ancestor => self)
end

#hashObject



31
32
33
# File 'lib/arel/algebra/attributes/attribute.rb', line 31

def hash
  @hash ||= name.hash + root.relation.hash
end

#to_attribute(relation) ⇒ Object



43
44
45
# File 'lib/arel/algebra/attributes/attribute.rb', line 43

def to_attribute(relation)
  bind(relation)
end