Sha256: 49aac1f270041c3d563077230e68b93c77b1c3ef8982e817e584a3a259a13b51

Contents?: true

Size: 430 Bytes

Versions: 1

Compression:

Stored size: 430 Bytes

Contents

require 'concurrent'
module Direct
  class Group
    def initialize
      @map = Concurrent::Map.new{|collection, key|
        collection.put(key, Concurrent::Array.new)
      }
    end

    attr_reader :map
    private :map

    def store(key, callable=nil, &block)
      map[key] << (callable || block)
      self
    end

    def fetch(key)
      map.fetch(key)
    end

    def key?(key)
      map.key?(key)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
direct-1.1.0 lib/direct/group.rb