Created
March 13, 2015 01:28
-
-
Save yasaichi/a552091afa33c5346c22 to your computer and use it in GitHub Desktop.
rails/rails/blob/4-2-stable/activesupport/lib/active_support/core_ext/hash/keys.rb
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
class Hash | |
def transform_keys | |
return enum_for(:transform_keys) unless block_given? | |
result = self.class.new | |
each_key do |key| | |
result[yield(key)] = self[key] | |
end | |
result | |
end | |
def symbolize_keys | |
transform_keys{ |key| key.to_sym rescue key } | |
end | |
alias_method :to_options, :symbolize_keys | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment