Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 16fe81a49a
Fetching contributors…

Cannot retrieve contributors at this time

18 lines (13 sloc) 0.657 kb
Throttle arbituary operation. Once limit is reached it will raise a Throttle::LimitExeeded exception.
Example:
Throttle.for("feed:#{request.remote_ip}", :max => 20, :in => 10.minutes) do
render :xml => Articles.all
end
If you want to clear the timeout for the current block ( for example: fraud protection. Clear the throttle when
the submitted Credit Card was valid. ) your block can accept a yielded throttle object and call the clear method
Throttle.for("cc:#{request.remote_ip}", :max => 20, :in => 10.minutes) do |throttle|
if am.pay(@credit_card)
throttle.clear
redirect_to :action => 'done'
end
end
Jump to Line
Something went wrong with that request. Please try again.