Module: Opro::Controllers::Concerns::RateLimits

Extended by:
ActiveSupport::Concern
Included in:
ApplicationControllerHelper
Defined in:
lib/opro/controllers/concerns/rate_limits.rb

Instance Method Summary collapse

Instance Method Details

#oauth_client_over_rate_limit?Boolean

override to implement custom rate limits

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/opro/controllers/concerns/rate_limits.rb', line 19

def oauth_client_over_rate_limit?
  return oauth_client_rate_limited?(oauth_client_app.id, params) unless oauth_client_app.blank?
  false
end

#oauth_client_rate_limited?(client_id, params) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/opro/controllers/concerns/rate_limits.rb', line 13

def oauth_client_rate_limited?(client_id, params)
  # implement your rate limiting algorithm here
end

#oauth_client_record_access!(client_id, params) ⇒ Object



9
10
11
# File 'lib/opro/controllers/concerns/rate_limits.rb', line 9

def oauth_client_record_access!(client_id, params)
  # implement your access counting mechanism here
end

#oauth_client_under_rate_limit?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/opro/controllers/concerns/rate_limits.rb', line 29

def oauth_client_under_rate_limit?
  !oauth_client_over_rate_limit?
end

#oauth_record_rate_limit!Object



24
25
26
27
# File 'lib/opro/controllers/concerns/rate_limits.rb', line 24

def oauth_record_rate_limit!
  return false if oauth_client_app.blank?
  oauth_client_record_access!(oauth_client_app.id, params)
end