Class: Trackguard::Adapters::Hub
- Defined in:
- lib/trackguard/adapters/hub.rb
Constant Summary collapse
- CACHE_KEY =
"trackguard/hub_rules"- STALE_KEY =
"trackguard/hub_rules/stale"- ETAG_KEY =
"trackguard/hub_rules/etag"
Instance Method Summary collapse
- #blocked_path?(path) ⇒ Boolean
- #blocked_user_agent?(user_agent) ⇒ Boolean
- #flagged_visitor?(ip) ⇒ Boolean
- #track_blocked_request(ip:, user_agent:, path:, http_method:, block_reason:) ⇒ Object
- #whitelisted_ip?(ip) ⇒ Boolean
Methods inherited from Base
Instance Method Details
#blocked_path?(path) ⇒ Boolean
19 20 21 22 23 |
# File 'lib/trackguard/adapters/hub.rb', line 19 def blocked_path?(path) rules.fetch(:blocked_paths, []).any? do |p| path.to_s.downcase.include?(p.downcase) end end |
#blocked_user_agent?(user_agent) ⇒ Boolean
13 14 15 16 17 |
# File 'lib/trackguard/adapters/hub.rb', line 13 def blocked_user_agent?(user_agent) rules.fetch(:blocked_user_agents, []).any? do |p| user_agent.to_s.downcase.include?(p.downcase) end end |
#flagged_visitor?(ip) ⇒ Boolean
29 30 31 |
# File 'lib/trackguard/adapters/hub.rb', line 29 def flagged_visitor?(ip) rules.fetch(:flagged_ips, []).include?(ip) end |
#track_blocked_request(ip:, user_agent:, path:, http_method:, block_reason:) ⇒ Object
33 34 35 |
# File 'lib/trackguard/adapters/hub.rb', line 33 def track_blocked_request(ip:, user_agent:, path:, http_method:, block_reason:) # placeholder: hub adapter does not persist blocked requests locally end |
#whitelisted_ip?(ip) ⇒ Boolean
25 26 27 |
# File 'lib/trackguard/adapters/hub.rb', line 25 def whitelisted_ip?(ip) rules.fetch(:whitelisted_ips, []).include?(ip) end |