Closed andrewcroome closed 8 years ago
I wonder if we could avoid having to add that extra alias
here by changing our approach in Dry::Container::Mixin
. Instead of using alias [] resolve
there (alias
is lexically scoped, which is why @andrewcroome has had to call it again inside the Stub
module), we could just make #[]
a proper method:
def [](key)
resolve(key)
end
This should mean that the Stub
mixing should work properly with #[]
without the need for the additional alias, right?
Yes, I think @timriley has the better way. I've amended this with that change.
@andrewcroome Fantastic, thank you!
When using stubs, resolving
:item
viacontainer.resolve(:item)
returns the stub.The small change included here ensures that
container[:item]
returns the stub as well.