diff options
author | Michael Herold <opensource@michaeljherold.com> | 2020-10-29 19:49:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-29 19:49:08 -0500 |
commit | 75410a6657090348de7bff3e5eab8aa684e49c38 (patch) | |
tree | 27e0eab23a209706b738bcfcf5736220fc3ac871 /lib/hashie/extensions/ignore_undeclared.rb | |
parent | 59d04c851e8ae80d82e93d82059e591eaa7718a7 (diff) | |
parent | f152e25912d0b93ff08b8964eb757200ad4b6f32 (diff) | |
download | hashie-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.rb | 9 |
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) |