diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-04 18:15:38 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-04 18:15:38 -0700 |
commit | 6b28dcfa7e03909b69b922e26eb6d3ad8eb3f061 (patch) | |
tree | b05e941417382e1851df6559f870ab48584e61a0 /lib/arel/sql/christener.rb | |
parent | 8f87072b1fc2b92328aa45078e535e9575b0b6cf (diff) | |
download | rails-6b28dcfa7e03909b69b922e26eb6d3ad8eb3f061.tar.gz rails-6b28dcfa7e03909b69b922e26eb6d3ad8eb3f061.tar.bz2 rails-6b28dcfa7e03909b69b922e26eb6d3ad8eb3f061.zip |
cleanup
Diffstat (limited to 'lib/arel/sql/christener.rb')
-rw-r--r-- | lib/arel/sql/christener.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/arel/sql/christener.rb b/lib/arel/sql/christener.rb new file mode 100644 index 0000000000..894f030342 --- /dev/null +++ b/lib/arel/sql/christener.rb @@ -0,0 +1,14 @@ +module Arel + module Sql + class Christener + def name_for(relation) + @used_names ||= Hash.new(0) + @relation_names ||= Hash.new do |h, k| + @used_names[k.name] += 1 + h[k] = k.name + (@used_names[k.name] > 1 ? "_#{@used_names[k.name]}" : '') + end + @relation_names[relation] + end + end + end +end
\ No newline at end of file |