Class: Pasaporte::Models::Throttle

Inherits:
Base
  • Object
show all
Defined in:
lib/pasaporte/models.rb

Overview

Set throttles

Class Method Summary collapse

Class Method Details

.set!(e) ⇒ Object

Set a throttle with the environment of the request



237
238
239
# File 'lib/pasaporte/models.rb', line 237

def self.set!(e)
  create(:client_fingerprint => env_hash(e))
end

.throttled?(e) ⇒ Boolean

Check if an environment is throttled

Returns:

  • (Boolean)


242
243
244
245
# File 'lib/pasaporte/models.rb', line 242

def self.throttled?(e)
  prune!
  count(:conditions => ["client_fingerprint = ? AND created_at > ?", env_hash(e), cutoff]) > 0
end