Class: Stumb::Store

Inherits:
Object
  • Object
show all
Includes:
Enumerable, MonitorMixin
Defined in:
lib/stumb/store.rb

Instance Method Summary collapse

Constructor Details

#initializeStore

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

#sizeObject



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