Class: Cash::Mock
- Inherits:
-
HashWithIndifferentAccess
- Object
- HashWithIndifferentAccess
- Cash::Mock
- Defined in:
- lib/cash/mock.rb
Instance Attribute Summary collapse
-
#servers ⇒ Object
Returns the value of attribute servers.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #add(key, value, *options) ⇒ Object
- #append(key, value) ⇒ Object
- #decr(key, amount = 1) ⇒ Object
- #delete(key, *options) ⇒ Object
- #flush_all ⇒ Object
- #get(key, *args) ⇒ Object
- #get_multi(*values) ⇒ Object
- #incr(key, amount = 1) ⇒ Object
- #namespace ⇒ Object
- #reset_runtime ⇒ Object
- #set(key, value, *options) ⇒ Object
- #stats ⇒ Object
Instance Attribute Details
#servers ⇒ Object
Returns the value of attribute servers.
3 4 5 |
# File 'lib/cash/mock.rb', line 3 def servers @servers end |
Instance Method Details
#[](key) ⇒ Object
13 14 15 |
# File 'lib/cash/mock.rb', line 13 def [](key) deep_clone(super(key)) end |
#[]=(key, value) ⇒ Object
9 10 11 |
# File 'lib/cash/mock.rb', line 9 def []=(key, value) super(key, deep_clone(value)) end |
#add(key, value, *options) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/cash/mock.rb', line 35 def add(key, value, *) if self[key] "NOT_STORED\r\n" else self[key] = value "STORED\r\n" end end |
#append(key, value) ⇒ Object
48 49 50 |
# File 'lib/cash/mock.rb', line 48 def append(key, value) set(key, get(key).to_s + value.to_s) end |
#decr(key, amount = 1) ⇒ Object
30 31 32 33 |
# File 'lib/cash/mock.rb', line 30 def decr(key, amount = 1) self[key] ||= 0 self[key] -= amount end |
#delete(key, *options) ⇒ Object
44 45 46 |
# File 'lib/cash/mock.rb', line 44 def delete(key, *) self[key] = nil end |
#flush_all ⇒ Object
56 57 58 |
# File 'lib/cash/mock.rb', line 56 def flush_all clear end |
#get(key, *args) ⇒ Object
21 22 23 |
# File 'lib/cash/mock.rb', line 21 def get(key, *args) self[key] end |
#get_multi(*values) ⇒ Object
5 6 7 |
# File 'lib/cash/mock.rb', line 5 def get_multi(*values) reject { |k,v| !values.include? k } end |
#incr(key, amount = 1) ⇒ Object
25 26 27 28 |
# File 'lib/cash/mock.rb', line 25 def incr(key, amount = 1) self[key] ||= 0 self[key] += amount end |
#namespace ⇒ Object
52 53 54 |
# File 'lib/cash/mock.rb', line 52 def namespace nil end |
#reset_runtime ⇒ Object
64 65 66 |
# File 'lib/cash/mock.rb', line 64 def reset_runtime [0, Hash.new(0)] end |
#set(key, value, *options) ⇒ Object
17 18 19 |
# File 'lib/cash/mock.rb', line 17 def set(key, value, *) self[key] = value end |
#stats ⇒ Object
60 61 62 |
# File 'lib/cash/mock.rb', line 60 def stats {} end |