diff options
author | Vladimir Kochnev <hashtable@yandex.ru> | 2016-02-07 05:42:30 +0300 |
---|---|---|
committer | Vladimir Kochnev <hashtable@yandex.ru> | 2016-02-08 09:37:05 +0300 |
commit | c4fc51d48f92ab2dac1e0d13e152be2e1a1b3b28 (patch) | |
tree | 40ba75ec24b113e90f5e564bca08093f1e9e41b4 | |
parent | c0c85a68ecb88af00564f74af2889386975bb5a7 (diff) | |
download | hashie-c4fc51d48f92ab2dac1e0d13e152be2e1a1b3b28.tar.gz |
Refactor IgnoreUndeclared#initialize_attributes.
-rw-r--r-- | lib/hashie/extensions/ignore_undeclared.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/hashie/extensions/ignore_undeclared.rb b/lib/hashie/extensions/ignore_undeclared.rb index ce113fe..9b506dd 100644 --- a/lib/hashie/extensions/ignore_undeclared.rb +++ b/lib/hashie/extensions/ignore_undeclared.rb @@ -30,10 +30,13 @@ module Hashie # p.email # => NoMethodError 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 self.class.property?(att) || (self.class.respond_to?(:translations) && self.class.translations.include?(att)) + next unless klass.property?(att) || (translations && translations.include?(att)) self[att] = value - end if attributes + end end def property_exists?(property) |