matthewrudy / memoist

ActiveSupport::Memoizable with a few enhancements
MIT License
921 stars 99 forks source link

Implemented BlocksNotSupported extension #43

Open JelF opened 8 years ago

JelF commented 8 years ago

Implemented BlocksNotSupported extension to handle fact that blocks are not supported

closes https://github.com/matthewrudy/memoist/issues/39

JelF commented 8 years ago

fails in travis same as at master, porbably gemspec misconfiguration

matthewrudy commented 8 years ago

I never replied on this but the problem is that this makes it a runtime check any time you load a memoized method.

JelF commented 8 years ago

There is no way to check this outside runtime

TylerRick commented 3 years ago

This seems like something we should merge.

I just got bit by a bug where I was passing a block to a memoized method and trying to figure out why it was not seeing it (block_given? was false inside that method). If it had raised this error instead of silently ignoring (not passing on) my block, I would have found out about the problem immediately.

Personally, I think there should an option to let you pass blocks — useful if you can be sure you will pass the same block any time you pass the same arguments — but I can understand the reasoning behind this (Memoist can't be sure that you will pass the same block every time, and if you pass a different block that would have given a different result, it should not return the wrong result).