lib/receptacle/method_cache.rb in receptacle-0.2.0 vs lib/receptacle/method_cache.rb in receptacle-0.3.0

- old
+ new

@@ -11,10 +11,12 @@ attr_reader :wrappers # @return [Symbol] name of the before action method attr_reader :before_method_name # @return [Symbol] name of the after action method attr_reader :after_method_name + # @return [Integer] arity of strategy method according to https://ruby-doc.org/core-2.3.3/Method.html#method-i-arity + attr_reader :arity def initialize(method_name:, strategy:, before_wrappers:, after_wrappers:) @strategy = strategy @before_method_name = :"before_#{method_name}" @after_method_name = :"after_#{method_name}" @@ -22,9 +24,10 @@ before_wrappers ||= [] after_wrappers ||= [] @wrappers = before_wrappers | after_wrappers @skip_before_wrappers = before_wrappers.empty? @skip_after_wrappers = after_wrappers.empty? + @arity = strategy.new.method(method_name).arity end # @return [Boolean] true if no before wrappers need to be applied for this method def skip_before_wrappers? @skip_before_wrappers