Class: Lawkeeper::EnsureWare
- Inherits:
-
Object
- Object
- Lawkeeper::EnsureWare
- Defined in:
- lib/lawkeeper.rb
Instance Method Summary collapse
- #_call(env) ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ EnsureWare
constructor
A new instance of EnsureWare.
- #status_code ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ EnsureWare
Returns a new instance of EnsureWare.
88 89 90 91 |
# File 'lib/lawkeeper.rb', line 88 def initialize(app, = {}) @app = app @options = end |
Instance Method Details
#_call(env) ⇒ Object
97 98 99 100 101 102 103 104 105 |
# File 'lib/lawkeeper.rb', line 97 def _call(env) status, headers, body = @app.call(env) if headers.delete(AUTHORIZED_HEADER) || headers.delete(SKIPPED_HEADER) [status, headers, body] else [status_code, {"Content-Type" => "text/plain"}, ['forbidden, authorization required']] end end |
#call(env) ⇒ Object
93 94 95 |
# File 'lib/lawkeeper.rb', line 93 def call(env) dup._call(env) end |
#status_code ⇒ Object
107 108 109 |
# File 'lib/lawkeeper.rb', line 107 def status_code @options.fetch(:status_code, 403) end |