Class: Direct::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/direct/group.rb

Instance Method Summary collapse

Constructor Details

#initializeGroup

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

Returns:

  • (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

#inspectObject



30
31
32
# File 'lib/direct/group.rb', line 30

def inspect
  map.keys.inspect
end

#key?(key) ⇒ Boolean

Returns:

  • (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