lib/emittance/dispatcher/registration_collection_proxy.rb in emittance-1.0.0 vs lib/emittance/dispatcher/registration_collection_proxy.rb in emittance-1.1.0

- old
+ new

@@ -4,22 +4,25 @@ class Dispatcher ## # A collection proxy for registrations. Can include multiple key/value pairs. # class RegistrationCollectionProxy + include Enumerable + # @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.flatten.each(*args, &blk) - self + def each + return enum_for(:each) unless block_given? + + arrays.flatten.each do |registration| + yield registration + end end # @return [Boolean] true if there are no registrations at all, false otherwise def empty? mappings.values.all?(&:empty?)