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