Module: Arel::Relation::AttributeAccessable

Included in:
Arel::Relation
Defined in:
lib/arel/algebra/relations/relation.rb

Instance Method Summary collapse

Instance Method Details

#[](index) ⇒ Object



86
87
88
# File 'lib/arel/algebra/relations/relation.rb', line 86

def [](index)
  attributes[index]
end

#find_attribute_matching_attribute(attribute) ⇒ Object



94
95
96
97
98
# File 'lib/arel/algebra/relations/relation.rb', line 94

def find_attribute_matching_attribute(attribute)
  matching_attributes(attribute).max do |a1, a2|
    (a1.original_attribute / attribute) <=> (a2.original_attribute / attribute)
  end
end

#find_attribute_matching_name(name) ⇒ Object



90
91
92
# File 'lib/arel/algebra/relations/relation.rb', line 90

def find_attribute_matching_name(name)
  attributes.detect { |a| a.named?(name) } || Attribute.new(self, name)
end

#position_of(attribute) ⇒ Object



100
101
102
103
104
# File 'lib/arel/algebra/relations/relation.rb', line 100

def position_of(attribute)
  (@position_of ||= Hash.new do |h, attribute|
    h[attribute] = attributes.index(self[attribute])
  end)[attribute]
end