diff options
author | Prem Sichanugrist <s@sikachu.com> | 2011-04-10 12:27:26 +0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2011-04-10 16:47:50 +0800 |
commit | 63cd92f9f346acefca1ad014873c971837843cdb (patch) | |
tree | 23be83a25e191359502ae7b95e83deee97ba93fe /railties/lib/rails/generators/named_base.rb | |
parent | c0efc4009adb870ee23e93d46ac374f772d8cb4f (diff) | |
download | rails-63cd92f9f346acefca1ad014873c971837843cdb.tar.gz rails-63cd92f9f346acefca1ad014873c971837843cdb.tar.bz2 rails-63cd92f9f346acefca1ad014873c971837843cdb.zip |
Rails will now generate Ruby 1.9 style hash when running scaffold_controller generator on Ruby 1.9.x
The new hash syntax of Ruby 1.9 looks more superior, so we decide to switch to it in the places that appropriate.
This patch has been requested by DHH.
Diffstat (limited to 'railties/lib/rails/generators/named_base.rb')
-rw-r--r-- | railties/lib/rails/generators/named_base.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 2af7f85463..3d19b372ff 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -181,6 +181,16 @@ module Rails class_collisions "#{options[:prefix]}#{name}#{options[:suffix]}" end end + + # Returns Ruby 1.9 style key-value pair if current code is running on + # Ruby 1.9.x. Returns the old-style (with hash rocket) otherwise. + def key_value(key, value) + if RUBY_VERSION < '1.9' + ":#{key} => #{value}" + else + "#{key}: #{value}" + end + end end end end |