diff options
author | Daniel Doubrovkine (dB.) @dblockdotorg <dblock@dblock.org> | 2016-02-08 10:44:27 -0500 |
---|---|---|
committer | Daniel Doubrovkine (dB.) @dblockdotorg <dblock@dblock.org> | 2016-02-08 10:44:27 -0500 |
commit | f63fc9974313214612c348a00629b691e8e5a54d (patch) | |
tree | 5865089c665fb5ed2133083de5df1190d1eeabcc /lib | |
parent | 6cfa2346a413eb88d1dd651ea7e925a41b668026 (diff) | |
parent | c4fc51d48f92ab2dac1e0d13e152be2e1a1b3b28 (diff) | |
download | hashie-f63fc9974313214612c348a00629b691e8e5a54d.tar.gz |
Merge pull request #350 from marshall-lee/fix_ignore_undeclared
Stringified translations wasn't working in IgnoreUndeclared.
Diffstat (limited to 'lib')
-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 e16e0a4..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.to_sym)) + next unless klass.property?(att) || (translations && translations.include?(att)) self[att] = value - end if attributes + end end def property_exists?(property) |