./lib/clean-hash/hash_pollute.rb in clean-hash-0.5.10 vs ./lib/clean-hash/hash_pollute.rb in clean-hash-0.5.11
- old
+ new
@@ -12,9 +12,13 @@
Marshal.load(Marshal.dump(self))
end
def to_ch mode=nil
if mode.is_a?(Array)
+ if not_alowed = (keys - mode).first
+ raise ArgumentError.new('CleanHash option "%s" is not alowed (%s)' % [not_alowed, mode.join(', ')])
+ end
+
mode.each { |el| self[el] = nil if self[el].nil? }
::CleanHash.create_struct self
else
mode ||= :indifferent
::CleanHash.create mode, self