Module: Raterr
- Defined in:
- lib/raterr.rb,
lib/raterr/day.rb,
lib/raterr/hour.rb,
lib/raterr/mixin.rb,
lib/raterr/minute.rb,
lib/raterr/version.rb,
lib/raterr/period_builder.rb
Defined Under Namespace
Modules: Mixin Classes: Day, Hour, Minute, PeriodBuilder
Constant Summary collapse
- AVAILABLE_PERIODS =
[:minute, :hour, :day, :week, :month].freeze
- DEFAULTS =
{ max: 100, code: 429, message: "Rate limit exceeded. Try again in %{time}.", period: :hour }.freeze
- VERSION =
"0.1.0"
Class Attribute Summary collapse
-
.store ⇒ Object
Returns the value of attribute store.
Class Method Summary collapse
Class Attribute Details
.store ⇒ Object
Returns the value of attribute store.
20 21 22 |
# File 'lib/raterr.rb', line 20 def store @store end |
Class Method Details
.enforce(request, **options) ⇒ Object
22 23 24 25 |
# File 'lib/raterr.rb', line 22 def enforce(request, **) period = PeriodBuilder.call(request, ) period.allowed? ? period.proceed : period.rate_limit_exceeded end |