Class: Jellyfish::Rewrite
- Inherits:
-
Struct
- Object
- Struct
- Jellyfish::Rewrite
- Defined in:
- lib/jellyfish/rewrite.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#from ⇒ Object
Returns the value of attribute from.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app
4 5 6 |
# File 'lib/jellyfish/rewrite.rb', line 4 def app @app end |
#from ⇒ Object
Returns the value of attribute from
4 5 6 |
# File 'lib/jellyfish/rewrite.rb', line 4 def from @from end |
#to ⇒ Object
Returns the value of attribute to
4 5 6 |
# File 'lib/jellyfish/rewrite.rb', line 4 def to @to end |
Instance Method Details
#call(env) ⇒ Object
5 6 7 8 9 |
# File 'lib/jellyfish/rewrite.rb', line 5 def call env app.call(env.merge( 'SCRIPT_NAME' => delete_suffix(env['SCRIPT_NAME'], from), 'PATH_INFO' => "#{to}#{env['PATH_INFO']}")) end |
#delete_suffix(str, suffix) ⇒ Object
12 13 14 |
# File 'lib/jellyfish/rewrite.rb', line 12 def delete_suffix str, suffix str.delete_suffix(suffix) end |