lib/prop/limiter.rb in prop-2.3.0 vs lib/prop/limiter.rb in prop-2.4.0

- old
+ new

@@ -44,20 +44,19 @@ # handle - the name of the handle you wish to use in your code, e.g. :login_attempt # defaults - the settings for this handle, e.g. { threshold: 5, interval: 5.minutes } # # Raises Prop::RateLimited if the number if the threshold for this handle has been reached def configure(handle, defaults) - raise ArgumentError.new("Invalid threshold setting") unless defaults[:threshold].to_i > 0 - raise ArgumentError.new("Invalid interval setting") unless defaults[:interval].to_i > 0 + Prop::Options.validate_options!(defaults) self.handles ||= {} self.handles[handle] = defaults end # Public: Disables Prop for a block of code # # block - a block of code within which Prop will not raise - def disabled(&block) + def disabled(&_block) @disabled = true yield ensure @disabled = false end