Skip to content
Browse files

Avoid adding Hash#symbolize_keys methods if ActiveSupport already def…

…ined them.
  • Loading branch information...
1 parent 3d9ca4a commit b0017cee9b3c58dcc48dbf7d9491e175691cebfa Nicolas Fouché committed Nov 9, 2009
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/ext/core_ext.rb
View
8 lib/ext/core_ext.rb
@@ -1,4 +1,4 @@
-class String
+String.class_eval do
def to_boolean
case self
when 'true'
@@ -11,17 +11,17 @@ def to_boolean
end
end
-class Hash
+Hash.class_eval do
def symbolize_keys
inject({}) do |options, (key, value)|
options[(key.to_sym rescue key) || key] = value
options
end
- end
+ end unless method_defined?(:symbolize_keys)
def symbolize_keys!
self.replace(self.symbolize_keys)
- end
+ end unless method_defined?(:symbolize_keys!)
def assert_has_keys(*valid_keys)
missing_keys = [valid_keys].flatten - keys

0 comments on commit b0017ce

Please sign in to comment.
Something went wrong with that request. Please try again.