lib/representable/hash_methods.rb in representable-3.0.4 vs lib/representable/hash_methods.rb in representable-3.1.0
- old
+ new
@@ -18,10 +18,11 @@
private
def filter_keys_for!(hash, options)
excluding = options[:exclude]
# TODO: use same filtering method as in normal representer in Representable#create_representation_with.
- return hash unless props = options.delete(:exclude) || options.delete(:include)
- hash.reject { |k,v| excluding ? props.include?(k.to_sym) : !props.include?(k.to_sym) }
+ return hash unless (props = (options.delete(:exclude) || options.delete(:include)))
+
+ hash.select { |k, _v| excluding ? !props.include?(k.to_sym) : props.include?(k.to_sym) }
end
end
end