Class: Rack::Session::EncryptedCookie
- Inherits:
-
Object
- Object
- Rack::Session::EncryptedCookie
show all
- Defined in:
- lib/rack/session/encryptedcookie.rb
Constant Summary
collapse
- NOT_FOUND =
[ 404, {}, [ 'Not found' ]].freeze
Instance Method Summary
collapse
Constructor Details
Returns a new instance of EncryptedCookie.
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/rack/session/encryptedcookie.rb', line 29
def initialize(app, opts={})
@app = app
@hash = {}
@opts = {
cookie_name: 'rack.session',
domain: nil,
http_only: false,
expires: (15 * 60),
cipher: 'aes-256-cbc',
salt: '3@bG>B@J5vy-FeXJ',
rounds: 2000,
key: 'r`*BqnG:c^;AL{k97=KYN!#',
tag_len: 16
}.merge(opts)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/rack/session/encryptedcookie.rb', line 62
def method_missing(method, *args, &block)
if @hash.respond_to?(method)
@hash.send(method, *args, &block)
else
raise ArgumentError.new("Method `#{method}` doesn't exist.")
end
end
|
Instance Method Details
#call(env) ⇒ Object
45
46
47
|
# File 'lib/rack/session/encryptedcookie.rb', line 45
def call(env)
dup.call!(env)
end
|
#call!(env) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/rack/session/encryptedcookie.rb', line 49
def call!(env)
@cb = env['async.callback']
env['async.callback'] = method(:save_session) if @cb
env['rack.session'] = self
load_session(env)
if @app
@cb ? @app.call(env) : save_session(@app.call(env))
else
@cb ? @cb.call(NOT_FOUND) : NOT_FOUND
end
end
|