Class: Juno::Stack
Overview
Combines multiple stores. Reads return the result from the first store, writes go to all stores.
Defined Under Namespace
Classes: DSL
Instance Attribute Summary collapse
- #stack ⇒ Object readonly
Instance Method Summary collapse
- #clear(options = {}) ⇒ Object
- #close ⇒ Object
- #delete(key, options = {}) ⇒ Object
-
#initialize(options = {}, &block) ⇒ Stack
constructor
A new instance of Stack.
- #key?(key, options = {}) ⇒ Boolean
- #load(key, options = {}) ⇒ Object
- #store(key, value, options = {}) ⇒ Object
Methods inherited from Base
Constructor Details
Instance Attribute Details
#stack ⇒ Object (readonly)
32 33 34 |
# File 'lib/juno/stack.rb', line 32 def stack @stack end |
Instance Method Details
#clear(options = {}) ⇒ Object
62 63 64 65 |
# File 'lib/juno/stack.rb', line 62 def clear( = {}) @stack.each {|s| s.clear } self end |
#close ⇒ Object
67 68 69 70 |
# File 'lib/juno/stack.rb', line 67 def close @stack.each {|s| s.close } nil end |
#delete(key, options = {}) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/juno/stack.rb', line 55 def delete(key, = {}) @stack.inject(nil) do |value, s| v = s.delete(key, ) value || v end end |
#key?(key, options = {}) ⇒ Boolean
38 39 40 |
# File 'lib/juno/stack.rb', line 38 def key?(key, = {}) @stack.any? {|s| s.key?(key) } end |
#load(key, options = {}) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/juno/stack.rb', line 42 def load(key, = {}) @stack.each do |s| value = s.load(key, ) return value if value end nil end |
#store(key, value, options = {}) ⇒ Object
50 51 52 53 |
# File 'lib/juno/stack.rb', line 50 def store(key, value, = {}) @stack.each {|s| s.store(key, value, ) } value end |