Class: Rack::CookieMonster
- Inherits:
-
Object
- Object
- Rack::CookieMonster
- Defined in:
- lib/rack/cookie_monster.rb
Defined Under Namespace
Classes: Hungry
Class Method Summary collapse
- .configure {|@config| ... } ⇒ Object
- .configure_for_rails ⇒ Object
- .cookies ⇒ Object
- .snackers ⇒ Object
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = nil) ⇒ CookieMonster
constructor
A new instance of CookieMonster.
Constructor Details
#initialize(app, opts = nil) ⇒ CookieMonster
Returns a new instance of CookieMonster.
39 40 41 42 |
# File 'lib/rack/cookie_monster.rb', line 39 def initialize(app, opts=nil) @app = app @config = opts.nil? ? self.class : CookieMonsterConfig.new(opts) end |
Class Method Details
.configure {|@config| ... } ⇒ Object
7 8 9 10 11 |
# File 'lib/rack/cookie_monster.rb', line 7 def configure @config ||= CookieMonsterConfig.new yield(@config) @configured = true end |
.configure_for_rails ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/rack/cookie_monster.rb', line 23 def configure_for_rails ensure_monster_configured! ActionController::Dispatcher.middleware.insert_before( ActionController::Base.session_store, self ) end |
.cookies ⇒ Object
18 19 20 21 |
# File 'lib/rack/cookie_monster.rb', line 18 def ensure_monster_configured! @config. end |
.snackers ⇒ Object
13 14 15 16 |
# File 'lib/rack/cookie_monster.rb', line 13 def snackers ensure_monster_configured! @config.snackers end |
Instance Method Details
#call(env) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/rack/cookie_monster.rb', line 44 def call(env) shares_with(env["HTTP_USER_AGENT"]) do request = ::Rack::Request.new(env) (env, request) end @app.call(env) end |