Class: Ww::Store
- Inherits:
-
Object
- Object
- Ww::Store
- Extended by:
- Forwardable
- Includes:
- Enumerable, MonitorMixin
- Defined in:
- lib/ww/store.rb
Instance Method Summary collapse
- #clear! ⇒ Object
- #each(descendant = true, &block) ⇒ Object
-
#initialize ⇒ Store
constructor
A new instance of Store.
- #storage ⇒ Object
- #store(obj) ⇒ Object
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
12 13 14 15 |
# File 'lib/ww/store.rb', line 12 def initialize super() @store = [] end |
Instance Method Details
#clear! ⇒ Object
29 30 31 |
# File 'lib/ww/store.rb', line 29 def clear! synchronize{ @store.clear } end |
#each(descendant = true, &block) ⇒ Object
25 26 27 |
# File 'lib/ww/store.rb', line 25 def each(descendant = true, &block) (descendant ? storage.reverse : storage).each(&block) end |
#storage ⇒ Object
17 18 19 |
# File 'lib/ww/store.rb', line 17 def storage synchronize { @store.dup } end |
#store(obj) ⇒ Object
21 22 23 |
# File 'lib/ww/store.rb', line 21 def store(obj) synchronize{ @store << obj } end |