Class: Rack::AddressMunging
- Inherits:
-
Object
- Object
- Rack::AddressMunging
- Defined in:
- lib/rack/address_munging.rb,
lib/rack/address_munging/version.rb,
lib/rack/address_munging/strategy.rb,
lib/rack/address_munging/detection.rb,
lib/rack/address_munging/strategy/hex.rb,
lib/rack/address_munging/strategy/rot13js.rb
Overview
The Rack::AddressMunging middleware, meant to be used in your Rack stack.
All other modules meant for use in your application are autoloaded here, so it should be enough just to require 'rack/address_munging' in your code.
To add the middleware to your stack, use: use Rack::AddressMunging
If you want to use another munging strategy, precise it as an argument: use Rack::AddressMunging, strategy: :hex
Defined Under Namespace
Constant Summary collapse
- VERSION =
'0.2.0'
Instance Attribute Summary collapse
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ AddressMunging
constructor
A new instance of AddressMunging.
Constructor Details
#initialize(app, options = {}) ⇒ AddressMunging
Returns a new instance of AddressMunging.
22 23 24 25 26 |
# File 'lib/rack/address_munging.rb', line 22 def initialize(app, = {}) @app = app @options = { strategy: :Hex }.merge() @strategy = Strategy.const_get(@options[:strategy]).new end |
Instance Attribute Details
#strategy ⇒ Object (readonly)
Returns the value of attribute strategy.
20 21 22 |
# File 'lib/rack/address_munging.rb', line 20 def strategy @strategy end |
Instance Method Details
#call(env) ⇒ Object
28 29 30 31 32 |
# File 'lib/rack/address_munging.rb', line 28 def call(env) @status, @headers, @response = @app.call(env) mung! if html? [@status, @headers, @response] end |