Class: Spy::Collection::Store
- Inherits:
-
Object
- Object
- Spy::Collection::Store
- Includes:
- Enumerable
- Defined in:
- lib/spy/collection/store.rb
Overview
Works with Entry abstractions to allow the store data structure to be easily swapped
Instance Method Summary collapse
- #each ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Store
constructor
A new instance of Store.
- #insert(entry) ⇒ Object
- #remove(entry) ⇒ Object
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
8 9 10 |
# File 'lib/spy/collection/store.rb', line 8 def initialize @internal = {} end |
Instance Method Details
#each ⇒ Object
20 21 22 23 24 25 |
# File 'lib/spy/collection/store.rb', line 20 def each e = Enumerator.new do |y| @internal.values.each {|v| y << v} end block_given? ? e.each(&Proc.new) : e end |
#empty? ⇒ Boolean
27 28 29 |
# File 'lib/spy/collection/store.rb', line 27 def empty? none? end |
#insert(entry) ⇒ Object
12 13 14 |
# File 'lib/spy/collection/store.rb', line 12 def insert(entry) @internal[entry.key] = entry end |
#remove(entry) ⇒ Object
16 17 18 |
# File 'lib/spy/collection/store.rb', line 16 def remove(entry) @internal.delete(entry.key) end |