Class: Direct::Group
- Inherits:
-
Object
- Object
- Direct::Group
- Defined in:
- lib/direct/group.rb
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #fetch(key) ⇒ Object
-
#initialize ⇒ Group
constructor
A new instance of Group.
- #inspect ⇒ Object
- #key?(key) ⇒ Boolean
- #store(key, callable = nil, &block) ⇒ Object
Constructor Details
#initialize ⇒ Group
Returns a new instance of Group.
4 5 6 7 8 |
# File 'lib/direct/group.rb', line 4 def initialize @map = Concurrent::Map.new{|collection, key| collection.put(key, Concurrent::Array.new) } end |
Instance Method Details
#empty? ⇒ Boolean
26 27 28 |
# File 'lib/direct/group.rb', line 26 def empty? map.empty? end |
#fetch(key) ⇒ Object
18 19 20 |
# File 'lib/direct/group.rb', line 18 def fetch(key) map.fetch(key) end |
#inspect ⇒ Object
30 31 32 |
# File 'lib/direct/group.rb', line 30 def inspect map.keys.inspect end |
#key?(key) ⇒ Boolean
22 23 24 |
# File 'lib/direct/group.rb', line 22 def key?(key) map.key?(key) end |
#store(key, callable = nil, &block) ⇒ Object
13 14 15 16 |
# File 'lib/direct/group.rb', line 13 def store(key, callable=nil, &block) map[key] << (callable || block) self end |