Class: Useless::Rack::Exceptions

Inherits:
Object
  • Object
show all
Defined in:
lib/useless/rack/exceptions.rb

Overview

‘Rack::Exceptions` sets ’low.show_exceptions’ to true if the request has been authenticated as an admin user.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Exceptions

Returns a new instance of Exceptions.



6
7
8
# File 'lib/useless/rack/exceptions.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/useless/rack/exceptions.rb', line 10

def call(env)
  # If low.show_exceptions has yet to be set,
  unless env['low.show_exceptions']

    # set it to true if
    env['low.show_exceptions'] =

      # the request has been authenticated,
      (!env['useless.user'].nil? and

      # and the user is an admin.
      (env['useless.user']['admin'] == true))
  end

  @app.call(env)
end