Class: CookieCutter::TestSupport::FakeCookieJar
- Inherits:
-
Object
- Object
- CookieCutter::TestSupport::FakeCookieJar
- Defined in:
- lib/cookie_cutter/test_support/fake_cookie_jar.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
- #delete(name, options) ⇒ Object
- #deleted?(name) ⇒ Boolean
-
#initialize(*args) ⇒ FakeCookieJar
constructor
A new instance of FakeCookieJar.
- #metadata_for(name) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(*args) ⇒ FakeCookieJar
Returns a new instance of FakeCookieJar.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cookie_cutter/test_support/fake_cookie_jar.rb', line 29 def initialize(*args) @cookies = {} @deleted_cookies = [] if args.any? = args.first .keys.each do || self[] = { value: [] } end end end |
Class Method Details
.empty! ⇒ Object
9 10 11 |
# File 'lib/cookie_cutter/test_support/fake_cookie_jar.rb', line 9 def empty! @instance = nil end |
.find ⇒ Object
5 6 7 |
# File 'lib/cookie_cutter/test_support/fake_cookie_jar.rb', line 5 def find @instance ||= FakeCookieJar.new end |
Instance Method Details
#[](name) ⇒ Object
14 15 16 17 |
# File 'lib/cookie_cutter/test_support/fake_cookie_jar.rb', line 14 def [](name) = @cookies[name] ? [:value] : nil end |
#[]=(name, value) ⇒ Object
19 20 21 22 |
# File 'lib/cookie_cutter/test_support/fake_cookie_jar.rb', line 19 def []=(name, value) @cookies[name] = value @deleted_cookies.delete_if{|n| name == n} end |
#delete(name, options) ⇒ Object
24 25 26 27 |
# File 'lib/cookie_cutter/test_support/fake_cookie_jar.rb', line 24 def delete(name, ) @cookies.delete(name) @deleted_cookies << name end |
#deleted?(name) ⇒ Boolean
40 41 42 |
# File 'lib/cookie_cutter/test_support/fake_cookie_jar.rb', line 40 def deleted?(name) @deleted_cookies.include?(name) end |
#metadata_for(name) ⇒ Object
48 49 50 |
# File 'lib/cookie_cutter/test_support/fake_cookie_jar.rb', line 48 def (name) @cookies[name] end |
#to_hash ⇒ Object
44 45 46 |
# File 'lib/cookie_cutter/test_support/fake_cookie_jar.rb', line 44 def to_hash @cookies end |