I discovered this when working on specs for dry-system.
There are two issues IMO:
(1) #decorate turns a non-memoized item into, effectively, a memoized one.
(2) The original item block is called immediately, when normally it would be called at resolve time. This difference in timing could introduce subtle bugs.
The added specs cover both problems.
Edit:
I've pushed a second commit which elaborates on this fix by generalizing #decorate, having it take a block instead of a class (or a stub, I guess, in the second path.) The user can then do anything with the original value in that block to decorate it. More flexible.
Add'l edit:
On second thought, original fix first, then maybe feature improvement.
I discovered this when working on specs for dry-system.
There are two issues IMO:
(1)
#decorate
turns a non-memoized item into, effectively, a memoized one. (2) The original item block is called immediately, when normally it would be called at resolve time. This difference in timing could introduce subtle bugs.The added specs cover both problems.
Edit:
I've pushed a second commit which elaborates on this fix by generalizing
#decorate
, having it take a block instead of a class (or a stub, I guess, in the second path.) The user can then do anything with the original value in that block to decorate it. More flexible.Add'l edit:
On second thought, original fix first, then maybe feature improvement.