diff options
author | dblock <dblock@dblock.org> | 2021-11-07 22:21:45 -0500 |
---|---|---|
committer | dblock <dblock@dblock.org> | 2021-11-07 22:21:45 -0500 |
commit | 25a3ff6e0498234d25de6a02bdbd3e508ade5898 (patch) | |
tree | 3ae1add7a8731daf46264b7a78cea9ac8b3278d0 /lib/hashie/extensions/dash | |
parent | 796f9446fe3313685fe1a5c74052e1e942d170a2 (diff) | |
parent | 98df995e2f0433d3d1abe46efd732bc8e20e31cc (diff) | |
download | hashie-25a3ff6e0498234d25de6a02bdbd3e508ade5898.tar.gz |
Merge branch 'dash-nil-keys' of https://github.com/michaelherold/hashie into michaelherold-dash-nil-keys
Diffstat (limited to 'lib/hashie/extensions/dash')
-rw-r--r-- | lib/hashie/extensions/dash/indifferent_access.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/hashie/extensions/dash/indifferent_access.rb b/lib/hashie/extensions/dash/indifferent_access.rb index 204cae6..50d4f93 100644 --- a/lib/hashie/extensions/dash/indifferent_access.rb +++ b/lib/hashie/extensions/dash/indifferent_access.rb @@ -19,6 +19,15 @@ module Hashie end private_class_method :requires_class_methods? + def to_h + defaults = ::Hash[self.class.properties.map do |prop| + [Hashie::Extensions::IndifferentAccess.convert_key(prop), self.class.defaults[prop]] + end] + + defaults.merge(self) + end + alias to_hash to_h + module ClassMethods # Check to see if the specified property has already been # defined. |