Class: Arel::Sql::Christener
- Inherits:
-
Object
- Object
- Arel::Sql::Christener
- Defined in:
- lib/arel/engines/sql/christener.rb
Instance Method Summary collapse
-
#initialize ⇒ Christener
constructor
A new instance of Christener.
- #name_for(relation) ⇒ Object
Constructor Details
#initialize ⇒ Christener
Returns a new instance of Christener.
4 5 6 |
# File 'lib/arel/engines/sql/christener.rb', line 4 def initialize @names = {} end |
Instance Method Details
#name_for(relation) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/arel/engines/sql/christener.rb', line 8 def name_for(relation) table = relation.table name = table.table_alias || table.name list = @names[name] ||= [] list << table unless list.include? table idx = list.index table name + (idx == 0 ? '' : "_#{idx + 1}") end |