class Emittance::Dispatcher::RegistrationCollectionProxy
A collection proxy for registrations. Can include multiple key/value pairs.
Attributes
lookup_term[R]
mappings[R]
Public Class Methods
new(lookup_term, mappings)
click to toggle source
@param lookup_term
the term initially used to lookup the registrations @param mappings [Hash] the mappings of identifiers to their respective registrations
# File lib/emittance/dispatcher/registration_collection_proxy.rb, line 13 def initialize(lookup_term, mappings) @lookup_term = lookup_term @mappings = mappings end
Public Instance Methods
<<(item)
click to toggle source
@return [RegistrationCollectionProxy] self
# File lib/emittance/dispatcher/registration_collection_proxy.rb, line 57 def <<(item) mappings[lookup_term] << item self end
[](idx)
click to toggle source
@param idx [Integer] the index you wish to find @return the registration indexed at the specified index
# File lib/emittance/dispatcher/registration_collection_proxy.rb, line 42 def [](idx) arrays.flatten[idx] end
clear()
click to toggle source
@return [RegistrationCollectionProxy] self
# File lib/emittance/dispatcher/registration_collection_proxy.rb, line 63 def clear mappings.values.each(&:clear) self end
each() { |registration| ... }
click to toggle source
@return [RegistrationCollectionProxy] self
# File lib/emittance/dispatcher/registration_collection_proxy.rb, line 19 def each return enum_for(:each) unless block_given? arrays.flatten.each do |registration| yield registration end end
empty?()
click to toggle source
@return [Boolean] true if there are no registrations at all, false otherwise
# File lib/emittance/dispatcher/registration_collection_proxy.rb, line 28 def empty? mappings.values.all?(&:empty?) end
first()
click to toggle source
@return the registration at the first index
# File lib/emittance/dispatcher/registration_collection_proxy.rb, line 47 def first self[0] end
last()
click to toggle source
@return the registration at the last index
# File lib/emittance/dispatcher/registration_collection_proxy.rb, line 52 def last self[-1] end
length()
click to toggle source
@return [Integer] the number of registrations that exist in the collection
# File lib/emittance/dispatcher/registration_collection_proxy.rb, line 33 def length arrays.flatten.length end
Private Instance Methods
arrays()
click to toggle source
# File lib/emittance/dispatcher/registration_collection_proxy.rb, line 72 def arrays mappings.values.map(&:to_a) end