Created
July 7, 2010 15:56
-
-
Save muffinista/466863 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/awsbase/support.rb b/lib/awsbase/support.rb | |
index 6d40f37..4b4b1fe 100644 | |
--- a/lib/awsbase/support.rb | |
+++ b/lib/awsbase/support.rb | |
@@ -1,7 +1,7 @@ | |
# If ActiveSupport is loaded, then great - use it. But we don't | |
# want a dependency on it, so if it's not present, define the few | |
# extensions that we want to use... | |
-unless defined? ActiveSupport::CoreExtensions | |
+ | |
# These are ActiveSupport-;like extensions to do a few handy things in the gems | |
# Derived from ActiveSupport, so the AS copyright notice applies: | |
# | |
@@ -30,15 +30,8 @@ unless defined? ActiveSupport::CoreExtensions | |
#++ | |
# | |
# | |
+unless defined? String.constantize | |
class String #:nodoc: | |
- | |
- # Constantize tries to find a declared constant with the name specified | |
- # in the string. It raises a NameError when the name is not in CamelCase | |
- # or is not initialized. | |
- # | |
- # Examples | |
- # "Module".constantize #=> Module | |
- # "Class".constantize #=> Class | |
def constantize() | |
unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ self | |
raise NameError, "#{self.inspect} is not a valid constant name!" | |
@@ -46,13 +39,15 @@ unless defined? ActiveSupport::CoreExtensions | |
Object.module_eval("::#{$1}", __FILE__, __LINE__) | |
end | |
+end | |
+unless defined? String.camelize | |
+ class String #:nodoc: | |
def camelize() | |
self.dup.split(/_/).map{ |word| word.capitalize }.join('') | |
end | |
- | |
end | |
- | |
+end | |
class Object #:nodoc: | |
# "", " ", nil, [], and {} are blank |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment