Class: Locomotive::Middlewares::Site
- Inherits:
-
Object
- Object
- Locomotive::Middlewares::Site
- Defined in:
- lib/locomotive/middlewares/site.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = {}) ⇒ Site
constructor
A new instance of Site.
Constructor Details
#initialize(app, opts = {}) ⇒ Site
Returns a new instance of Site.
7 8 9 |
# File 'lib/locomotive/middlewares/site.rb', line 7 def initialize(app, opts = {}) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/locomotive/middlewares/site.rb', line 11 def call(env) request = Rack::Request.new(env) # do not process "/assets" # only in dev, since the assets are precompiled in production if request_for_the_back_office_assets?(request) @app.call(env) else env['locomotive.site'] = site = fetch_site(request) # deal with the Steam entity instead of a Mongoid document env['steam.site'] = site.try(:to_steam) env['steam.is_default_host'] = default_host?(request) begin @app.call(env) rescue ::Locomotive::Steam::NoSiteException => exception handle_no_account_or_site(env, request) end end end |