From dd6b158d6d6e0cb937279f57e49eb6b19b5a801d Mon Sep 17 00:00:00 2001 From: Daniel Becker Date: Tue, 1 Aug 2017 14:54:17 +0200 Subject: [PATCH] Fix rails 5 deprecation warning. --- lib/virtus/attribute_set.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/virtus/attribute_set.rb b/lib/virtus/attribute_set.rb index 66055a84..5a04a508 100644 --- a/lib/virtus/attribute_set.rb +++ b/lib/virtus/attribute_set.rb @@ -193,9 +193,8 @@ def set_defaults(object, filter = method(:skip_default?)) # # @api private def coerce(attributes) - ::Hash.try_convert(attributes) or raise( - NoMethodError, "Expected #{attributes.inspect} to respond to #to_hash" - ) + (attributes.respond_to?(:permitted?) ? attributes.to_unsafe_h : ::Hash.try_convert(attributes)) || + raise(NoMethodError, "Expected #{attributes.inspect} to respond to #to_unsafe_hash") end # @api private