I'm having some trouble with the dry-auto_inject
Ruby gem when an object that responds to #to_hash
(such as Hanami::Entity
in my case) is passed as the last argument to .new
. When this happens, the generated .new
method implicitly converts the object to a hash (because #to_h
is for explicit conversion and #to_hash
is for implicit conversion, so the double splat operator converts the object), and when passed to #initialize
, the injected dependencies and the converted hash are passed altogether as a hash as the first argument.
require 'dry-container'
require 'dry-auto_inject'