summaryrefslogtreecommitdiff
path: root/lib/hashie/extensions/mash/symbolize_keys.rb
diff options
context:
space:
mode:
authorCaroline Artz <ceartz@gmail.com>2020-05-04 20:15:32 -0500
committerGitHub <noreply@github.com>2020-05-04 21:15:32 -0400
commit0bca9255a6234606cbdd98880ccc241f192cfdae (patch)
treed165924fdabec9b24edca434e2b0bd998d602e33 /lib/hashie/extensions/mash/symbolize_keys.rb
parentc066135a4bd6c75cd19fe342f768d2213df9e684 (diff)
downloadhashie-0bca9255a6234606cbdd98880ccc241f192cfdae.tar.gz
Changes to `Mash` initialization key string conversion. (#521)
Diffstat (limited to 'lib/hashie/extensions/mash/symbolize_keys.rb')
-rw-r--r--lib/hashie/extensions/mash/symbolize_keys.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/hashie/extensions/mash/symbolize_keys.rb b/lib/hashie/extensions/mash/symbolize_keys.rb
index 91a6b14..c0f2a4d 100644
--- a/lib/hashie/extensions/mash/symbolize_keys.rb
+++ b/lib/hashie/extensions/mash/symbolize_keys.rb
@@ -5,7 +5,7 @@ module Hashie
#
# @example
# class LazyResponse < Hashie::Mash
- # include Hashie::Extensions::Mash::SymbolizedKeys
+ # include Hashie::Extensions::Mash::SymbolizeKeys
# end
#
# response = LazyResponse.new("id" => 123, "name" => "Rey").to_h
@@ -24,13 +24,13 @@ module Hashie
private
- # Converts a key to a symbol
+ # Converts a key to a symbol, if possible
#
# @api private
- # @param [String, Symbol] key the key to convert to a symbol
- # @return [void]
+ # @param [<K>] key the key to attempt convert to a symbol
+ # @return [Symbol, K]
def convert_key(key)
- key.to_sym
+ key.respond_to?(:to_sym) ? key.to_sym : key
end
end
end