diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-02-27 12:18:18 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-02-27 12:18:18 -0800 |
commit | eb217b2cf02af3d6533fb5b0e3fe87efa78cf43a (patch) | |
tree | e8a063cca5fd052ba431e40bf1fb84dc4c34c450 /railties/lib/rails_generator | |
parent | f732c1680850639d119f897f3116eb1f1f987134 (diff) | |
download | rails-eb217b2cf02af3d6533fb5b0e3fe87efa78cf43a.tar.gz rails-eb217b2cf02af3d6533fb5b0e3fe87efa78cf43a.tar.bz2 rails-eb217b2cf02af3d6533fb5b0e3fe87efa78cf43a.zip |
Ruby 1.9 compat: limit const_defined?
Diffstat (limited to 'railties/lib/rails_generator')
-rw-r--r-- | railties/lib/rails_generator/commands.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/railties/lib/rails_generator/commands.rb b/railties/lib/rails_generator/commands.rb index 299044c3d7..b684dc92be 100644 --- a/railties/lib/rails_generator/commands.rb +++ b/railties/lib/rails_generator/commands.rb @@ -182,15 +182,19 @@ HELP nesting = class_name.split('::') name = nesting.pop + # Hack to limit const_defined? to non-inherited on 1.9. + extra = [] + extra << false unless Object.method(:const_defined?).arity == 1 + # Extract the last Module in the nesting. last = nesting.inject(Object) { |last, nest| - break unless last.const_defined?(nest) + break unless last.const_defined?(nest, *extra) last.const_get(nest) } # If the last Module exists, check whether the given # class exists and raise a collision if so. - if last and last.const_defined?(name.camelize) + if last and last.const_defined?(name.camelize, *extra) raise_class_collision(class_name) end end |