lib/rate_limiter/controller.rb in rate_limiter-0.0.4 vs lib/rate_limiter/controller.rb in rate_limiter-0.0.5
- old
+ new
@@ -1,11 +1,10 @@
module RateLimiter
module Controller
def self.included(base)
- base.before_filter :set_rate_limiter_source
- base.before_filter :set_rate_limiter_controller_info
base.before_filter :set_rate_limiter_enabled_for_controller
+ base.before_filter :set_rate_limiter_source, :set_rate_limiter_controller_info
end
protected
def user_for_rate_limiter
@@ -21,14 +20,14 @@
end
private
def set_rate_limiter_source
- ::RateLimiter.source = user_for_rate_limiter
+ ::RateLimiter.source = user_for_rate_limiter if rate_limiter_enabled_for_controller
end
def set_rate_limiter_controller_info
- ::RateLimiter.controller_info = info_for_rate_limiter
+ ::RateLimiter.controller_info = info_for_rate_limiter if rate_limiter_enabled_for_controller
end
def set_rate_limiter_enabled_for_controller
::RateLimiter.enabled_for_controller = rate_limiter_enabled_for_controller
end