module RateLimiter::Model::ClassMethods
Class methods available to models after RateLimiter
has been loaded.
Public Instance Methods
rate_limit(options = {})
click to toggle source
Tell the model to limit creation of records based on an attribute for a given interval of time.
Options:
-
:on - The attribute to limit on. Defaults to `:ip_address`. Set to an
array to limit on multiple attributes (e.g. `:ip_address` or `:user_id`.
-
:interval - The amount of time that must have elapses since the last
record that has the same value as the attribute indicated by the `:on` option in seconds. Defaults to 1 minute.
-
:if, :unless - Procs that specify the conditions for when record
creation rate limiting should occur.
# File lib/rate_limiter/model.rb, line 27 def rate_limit(options = {}) defaults = RateLimiter.config.rate_limit_defaults rate_limiter.setup(defaults.merge(options)) end
rate_limiter()
click to toggle source
# File lib/rate_limiter/model.rb, line 32 def rate_limiter ModelConfig.new(self) end