Class: Rack::ScreenDoor
- Inherits:
-
Object
- Object
- Rack::ScreenDoor
- Includes:
- ERB::Util
- Defined in:
- lib/rack/screen_door.rb,
lib/rack/screen_door/version.rb
Overview
Rack middleware class for simple question and answer authorization.
Constant Summary collapse
- DEFAULT_COOKIE_KEY =
'_rack_screen_door'
- DEFAULT_COOKIE_HASH =
{ :path => '/', :httponly => true }
- DEFAULT_EXPIRES =
1 month
60 * 60 * 24 * 30
- DEFAULT_TEMPLATE_PATH =
::File.('../../../default_template.html.erb', __FILE__)
- DEFAULT_SALT =
'SaltySalt'
- VERSION =
"0.0.4"
Instance Attribute Summary collapse
-
#answer ⇒ Object
readonly
Returns the value of attribute answer.
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#bypass_if ⇒ Object
readonly
Returns the value of attribute bypass_if.
-
#cookie_hash ⇒ Object
readonly
Returns the value of attribute cookie_hash.
-
#cookie_key ⇒ Object
readonly
Returns the value of attribute cookie_key.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#expires ⇒ Object
readonly
Returns the value of attribute expires.
-
#redirect_url ⇒ Object
readonly
Returns the value of attribute redirect_url.
-
#salt ⇒ Object
readonly
Returns the value of attribute salt.
-
#template_path ⇒ Object
readonly
Returns the value of attribute template_path.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Rack middleware chain.
-
#initialize(app, answer, options = {}) ⇒ ScreenDoor
constructor
Creates the middleware.
Constructor Details
#initialize(app, answer, options = {}) ⇒ ScreenDoor
Creates the middleware.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rack/screen_door.rb', line 35 def initialize(app, answer, = {}) @app = app @answer = answer @salt = [:salt] || DEFAULT_SALT @template_path = [:template_path] || DEFAULT_TEMPLATE_PATH @cookie_key = [:cookie_key] || DEFAULT_COOKIE_KEY @cookie_hash = DEFAULT_COOKIE_HASH.merge([:cookie_hash] || {}) @expires = [:expires] || DEFAULT_EXPIRES @bypass_if = [:bypass_if] end |
Instance Attribute Details
#answer ⇒ Object (readonly)
Returns the value of attribute answer.
18 19 20 |
# File 'lib/rack/screen_door.rb', line 18 def answer @answer end |
#app ⇒ Object (readonly)
Returns the value of attribute app.
17 18 19 |
# File 'lib/rack/screen_door.rb', line 17 def app @app end |
#bypass_if ⇒ Object (readonly)
Returns the value of attribute bypass_if.
18 19 20 |
# File 'lib/rack/screen_door.rb', line 18 def bypass_if @bypass_if end |
#cookie_hash ⇒ Object (readonly)
Returns the value of attribute cookie_hash.
17 18 19 |
# File 'lib/rack/screen_door.rb', line 17 def @cookie_hash end |
#cookie_key ⇒ Object (readonly)
Returns the value of attribute cookie_key.
17 18 19 |
# File 'lib/rack/screen_door.rb', line 17 def @cookie_key end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
19 20 21 |
# File 'lib/rack/screen_door.rb', line 19 def error @error end |
#expires ⇒ Object (readonly)
Returns the value of attribute expires.
17 18 19 |
# File 'lib/rack/screen_door.rb', line 17 def expires @expires end |
#redirect_url ⇒ Object (readonly)
Returns the value of attribute redirect_url.
19 20 21 |
# File 'lib/rack/screen_door.rb', line 19 def redirect_url @redirect_url end |
#salt ⇒ Object (readonly)
Returns the value of attribute salt.
18 19 20 |
# File 'lib/rack/screen_door.rb', line 18 def salt @salt end |
#template_path ⇒ Object (readonly)
Returns the value of attribute template_path.
18 19 20 |
# File 'lib/rack/screen_door.rb', line 18 def template_path @template_path end |
Instance Method Details
#call(env) ⇒ Object
Rack middleware chain.
47 48 49 |
# File 'lib/rack/screen_door.rb', line 47 def call(env) dup._call(env) # make threadsafe end |