diff options
author | James Wen <jrw2175@columbia.edu> | 2016-01-03 00:43:05 -0500 |
---|---|---|
committer | James Wen <jrw2175@columbia.edu> | 2016-01-03 00:43:05 -0500 |
commit | a5da09c97c6e7e2be482809dbf0c019178d34176 (patch) | |
tree | 9eba296c9fde7bd872fc8af3f41c71033b145b56 | |
parent | cb0a52226166a6772642ca8dfbbbd4acee1c8e51 (diff) | |
download | bundler-a5da09c97c6e7e2be482809dbf0c019178d34176.tar.gz |
Refactor `SharedHelpers#const_get_safely` to maintain support for ruby 1.8.7
- `Module#constants` returns an array of strings instead of symbols in
`ruby 1.8.7`, check for presence of both string and symbol forms of
`constant_name` in constants
-rw-r--r-- | lib/bundler/shared_helpers.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index cfa37e7f88..5456c2da88 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -119,9 +119,10 @@ module Bundler end def const_get_safely(constant_name, namespace) - constant_sym = constant_name.to_sym - return nil unless namespace.constants.include? constant_sym - namespace.const_get(constant_sym) + const_in_namespace = namespace.constants.include?(constant_name.to_s) || + namespace.constants.include?(constant_name.to_sym) + return nil unless const_in_namespace + namespace.const_get(constant_name) end private |