Class: IpAnonymizer::HashIp
- Inherits:
-
Object
- Object
- IpAnonymizer::HashIp
- Defined in:
- lib/ip_anonymizer/hash_ip.rb
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) # TODO lazy load, like ActionDispatch::RemoteIp req.remote_ip = IpAnonymizer.hash_ip(req.remote_ip, key: @key) @app.call(req.env) end |