summaryrefslogtreecommitdiff
path: root/lib/hashie/extensions/ignore_undeclared.rb
diff options
context:
space:
mode:
authorMichael Herold <opensource@michaeljherold.com>2020-10-29 19:49:08 -0500
committerGitHub <noreply@github.com>2020-10-29 19:49:08 -0500
commit75410a6657090348de7bff3e5eab8aa684e49c38 (patch)
tree27e0eab23a209706b738bcfcf5736220fc3ac871 /lib/hashie/extensions/ignore_undeclared.rb
parent59d04c851e8ae80d82e93d82059e591eaa7718a7 (diff)
parentf152e25912d0b93ff08b8964eb757200ad4b6f32 (diff)
downloadhashie-75410a6657090348de7bff3e5eab8aa684e49c38.tar.gz
Merge pull request #537 from michaelherold/dash-consistency
Fix inconsistencies with Dash defaults
Diffstat (limited to 'lib/hashie/extensions/ignore_undeclared.rb')
-rw-r--r--lib/hashie/extensions/ignore_undeclared.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/hashie/extensions/ignore_undeclared.rb b/lib/hashie/extensions/ignore_undeclared.rb
index 9b506dd..64cf0b6 100644
--- a/lib/hashie/extensions/ignore_undeclared.rb
+++ b/lib/hashie/extensions/ignore_undeclared.rb
@@ -31,12 +31,11 @@ module Hashie
module IgnoreUndeclared
def initialize_attributes(attributes)
return unless attributes
+
klass = self.class
- translations = klass.respond_to?(:translations) && klass.translations
- attributes.each_pair do |att, value|
- next unless klass.property?(att) || (translations && translations.include?(att))
- self[att] = value
- end
+ translations = klass.respond_to?(:translations) && klass.translations || []
+
+ super(attributes.select { |attr, _| klass.property?(attr) || translations.include?(attr) })
end
def property_exists?(property)