Sha256: b4b968170aeef4a9116542aa07d03af1c30a59f1227f1d283bb06e35734830c7
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true module Emittance class Dispatcher ## # A collection proxy for registrations. Can include multiple key/value pairs. # class RegistrationCollectionProxy # @param lookup_term the term initially used to lookup the registrations # @param mappings [Hash] the mappings of identifiers to their respective registrations def initialize(lookup_term, mappings) @lookup_term = lookup_term @mappings = mappings end # @param args args passed to +Array#each+ # @param blk block passed to +Array#each+ # @return [RegistrationCollectionProxy] self def each(*args, &blk) arrays = mappings.values.map(&:to_a) arrays.flatten.each(*args, &blk) self end # @return [Boolean] true if there are no registrations at all, false otherwise def empty? mappings.values.all?(&:empty?) end # @return [RegistrationCollectionProxy] self def <<(item) mappings[lookup_term] << item self end # @return [RegistrationCollectionProxy] self def clear mappings.values.each(&:clear) self end private attr_reader :lookup_term, :mappings end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
emittance-0.1.0 | lib/emittance/dispatcher/registration_collection_proxy.rb |