Module: Rack::Attack::PeriodIntrospection
- Included in:
- InstantiableFail2Ban, Throttle
- Defined in:
- lib/rack/attack_extensions.rb
Overview
class << self
Instance Method Summary collapse
-
#time_range(time_bucket) ⇒ Object
time_bucket is epoch_time / period.
Instance Method Details
#time_range(time_bucket) ⇒ Object
time_bucket is epoch_time / period
191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/rack/attack_extensions.rb', line 191 def time_range(time_bucket) time_bucket = time_bucket.to_i start_time = Time.at(time_bucket * period) end_time = Time.at(start_time + period) duration = ActiveSupport::Duration.build(end_time - start_time) (start_time .. end_time).tap do |time_range| # @return [ActiveSupport::Duration] time_range.define_singleton_method :duration do duration end end end |