summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Wen <jrw2175@columbia.edu>2016-01-03 00:43:05 -0500
committerJames Wen <jrw2175@columbia.edu>2016-01-03 00:43:05 -0500
commita5da09c97c6e7e2be482809dbf0c019178d34176 (patch)
tree9eba296c9fde7bd872fc8af3f41c71033b145b56
parentcb0a52226166a6772642ca8dfbbbd4acee1c8e51 (diff)
downloadbundler-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.rb7
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