Module: Cutoff::Rails::Controller
- Defined in:
- lib/cutoff/rails/controller.rb
Overview
Rails controller integration
Instance Method Summary collapse
-
#cutoff(seconds, options = {}) ⇒ Object
Set a cutoff for the controller.
Instance Method Details
#cutoff(seconds, options = {}) ⇒ Object
Set a cutoff for the controller
Can be called multiple times with different options to configure cutoffs for various conditions. If multiple conditions match a given controller, the last applied cutoff "wins".
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cutoff/rails/controller.rb', line 33 def cutoff(seconds, = {}) prepend_around_action() do |_controller, action| next action.call if @cutoff_wrapped begin @cutoff_wrapped = true Cutoff.wrap(seconds, &action) ensure @cutoff_wrapped = false end end end |