Hello I am in the process of upgrading Ruby for our app from 2.5.1 to 3.3.0.
We have the following code which was working in 2.5.1:
require "dry-container"
require "dry-auto_inject"
module Dealer
class Container
extend Dry::Container::Mixin
register(:get_device_time_zone) do
GetDeviceTimeZone.new
end
After upgrading to ruby 3.3.0 we started seeing the following error:
/gems/ruby/3.3.0/gems/dry-container-0.11.0/lib/dry/container/mixin.rb:155:in `register': undefined method `call' for an instance of Hash (NoMethodError)
config.registry.call(_container, key, item, options)
I ran the code through the debugger and I see the following:
From: /gems/ruby/3.3.0/gems/dry-container-0.11.0/lib/dry/container/mixin.rb:155 Dry::Container::Mixin#register:
147: def register(key, contents = nil, options = EMPTY_HASH, &block)
148: if block_given?
149: item = block
150: options = contents if contents.is_a?(::Hash)
151: else
152: item = contents
153: end
154:
=> 155: binding.pry
156: config.registry.call(_container, key, item, options)
157:
158: self
159: rescue FrozenError
160: raise FrozenError,
161: "can't modify frozen #{self.class} (when attempting to register '#{key}')"
162: end
[1] pry(NexiaDealer::Container)> config
=> #<#<Class:0x00007cab56ab2da8>:0x00007cab558ce150 @config={:namespace_separator=>{:default=>"."}, :resolver=>{:default=>#<Dry::Container::Resolver:0x00007cab559987e8>}, :registry=>{:default=>#<Dry::Container::Registry:0x00007cab55998748 @_mutex=#<Thread::Mutex:0x00007cab559986d0>>}}>
The config.registry is a hash with a default key. I just started diving into this so I am not sure why this is happening. Any help would be appreciated.