summaryrefslogtreecommitdiff
path: root/lib/hashie/extensions/ignore_undeclared.rb
diff options
context:
space:
mode:
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)