Class: Rack::CookieMonsterConfig

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ CookieMonsterConfig

Returns a new instance of CookieMonsterConfig.



92
93
94
95
# File 'lib/rack/cookie_monster.rb', line 92

def initialize(opts={})
  @cookies = [opts[:cookies]].compact.flatten.map { |x| x.to_sym }
  @snackers = [opts[:share_with]].compact.flatten
end

Instance Attribute Details

#cookiesObject (readonly)

Returns the value of attribute cookies.



90
91
92
# File 'lib/rack/cookie_monster.rb', line 90

def cookies
  @cookies
end

#snackersObject (readonly)

Returns the value of attribute snackers.



90
91
92
# File 'lib/rack/cookie_monster.rb', line 90

def snackers
  @snackers
end

Instance Method Details

#eat(cookie) ⇒ Object



97
98
99
# File 'lib/rack/cookie_monster.rb', line 97

def eat(cookie)
  @cookies << cookie.to_sym
end

#share_with(snacker) ⇒ Object



101
102
103
# File 'lib/rack/cookie_monster.rb', line 101

def share_with(snacker)
  @snackers << snacker
end