Class: Decidim::DecidimAwesome::CurrentConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/decidim_awesome/middleware/current_config.rb

Overview

A middleware that stores the current awesome context by parsing the request

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ CurrentConfig

Initializes the Rack Middleware.

app - The Rack application



10
11
12
# File 'lib/decidim/decidim_awesome/middleware/current_config.rb', line 10

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Main entry point for a Rack Middleware.

env - A Hash.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/decidim/decidim_awesome/middleware/current_config.rb', line 17

def call(env)
  @request = Rack::Request.new(env)
  if @request.env["decidim.current_organization"] && processable_path?
    # memoize for later
    @config = env["decidim_awesome.current_config"] = awesome_config_instance
    tamper_user_model
    add_flash_message_from_request(env)
  else
    reset_user_model
  end

  @app.call(env)
end