Class: IpAnonymizer::HashIp
- Inherits:
-
Object
- Object
- IpAnonymizer::HashIp
- Defined in:
- lib/ip_anonymizer/hash_ip.rb
Defined Under Namespace
Classes: GetIp
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, key:) ⇒ HashIp
constructor
A new instance of HashIp.
Constructor Details
#initialize(app, key:) ⇒ HashIp
Returns a new instance of HashIp.
3 4 5 6 |
# File 'lib/ip_anonymizer/hash_ip.rb', line 3 def initialize(app, key:) @app = app @key = key end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/ip_anonymizer/hash_ip.rb', line 8 def call(env) req = ActionDispatch::Request.new(env) # get header directly to preserve ActionDispatch::RemoteIp lazy loading req.remote_ip = GetIp.new(req.get_header("action_dispatch.remote_ip".freeze), @key) @app.call(req.env) end |