Class: Locomotive::Middlewares::LocaleRedirection

Inherits:
Base
  • Object
show all
Defined in:
lib/locomotive/middlewares/locale_redirection.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, opts = {}) ⇒ LocaleRedirection

Returns a new instance of LocaleRedirection.



5
6
7
# File 'lib/locomotive/middlewares/locale_redirection.rb', line 5

def initialize(app, opts = {})
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/locomotive/middlewares/locale_redirection.rb', line 9

def call(env)
  if url = redirect_url(env)
    redirect_to url
  else
    @app.call(env)
  end
end