Class: Stumb::Store
- Inherits:
-
Object
- Object
- Stumb::Store
- Includes:
- Enumerable, MonitorMixin
- Defined in:
- lib/stumb/store.rb
Instance Method Summary collapse
- #clear! ⇒ Object
- #each(descendant = true, &block) ⇒ Object
-
#initialize ⇒ Store
constructor
A new instance of Store.
- #size ⇒ Object
- #store(obj) ⇒ Object
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
8 9 10 11 |
# File 'lib/stumb/store.rb', line 8 def initialize super() @store = [] end |
Instance Method Details
#clear! ⇒ Object
26 27 28 |
# File 'lib/stumb/store.rb', line 26 def clear! @store.clear end |
#each(descendant = true, &block) ⇒ Object
17 18 19 20 |
# File 'lib/stumb/store.rb', line 17 def each(descendant = true, &block) store = synchronize{ @store.dup } (descendant ? store.reverse : store).each(&block) end |
#size ⇒ Object
22 23 24 |
# File 'lib/stumb/store.rb', line 22 def size synchronize{ @store.size } end |
#store(obj) ⇒ Object
13 14 15 |
# File 'lib/stumb/store.rb', line 13 def store(obj) synchronize{ @store << obj } end |