File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3+ require "dry/core/deprecations"
4+
35module Dry
46 module Core
57 module Memoizable
@@ -80,6 +82,15 @@ def #{method.name}
8082 mapping = parameters . to_h { |k , v = nil | [ k , v ] }
8183 params , binds = declaration ( parameters , mapping )
8284
85+ if parameters . last [ 0 ] . eql? ( :block )
86+ Deprecations . warn ( <<~WARN )
87+ Memoization for block-accepting methods isn't safe.
88+ Every call creates a new block instance bloating cached results.
89+ In the future, blocks will still be allowed but won't participate in
90+ cache key calculation.
91+ WARN
92+ end
93+
8394 module_eval <<~RUBY , __FILE__ , __LINE__ + 1
8495 def #{ method . name } (#{ params . join ( ", " ) } )
8596 key = [:"#{ method . name } ", #{ binds . join ( ", " ) } ].hash
You can’t perform that action at this time.
0 commit comments