Class: Jellyfish::Rewrite

Inherits:
Struct
  • Object
show all
Defined in:
lib/jellyfish/rewrite.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#appObject

Returns the value of attribute app

Returns:

  • (Object)

    the current value of app



4
5
6
# File 'lib/jellyfish/rewrite.rb', line 4

def app
  @app
end

#fromObject

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



4
5
6
# File 'lib/jellyfish/rewrite.rb', line 4

def from
  @from
end

#toObject

Returns the value of attribute to

Returns:

  • (Object)

    the current value of 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