class IO::Endpoint::CompositeEndpoint
A composite endpoint is a collection of endpoints that are used in order.
def bind(wrapper = self.wrapper, &block)
def bind(wrapper = self.wrapper, &block) if block_given? @endpoints.each do |endpoint| endpoint.bind(&block) end else @endpoints.map(&:bind).flatten.compact end end
def connect(wrapper = self.wrapper, &block)
def connect(wrapper = self.wrapper, &block) last_error = nil @endpoints.each do |endpoint| begin return endpoint.connect(wrapper, &block) rescue => last_error end end raise last_error end
def each(&block)
def each(&block) @endpoints.each do |endpoint| endpoint.each(&block) end end
def initialize(endpoints, **options)
def initialize(endpoints, **options) super(**options) # If any options were provided, propagate them to the endpoints: if options.any? endpoints = endpoints.map{|endpoint| endpoint.with(**options)} end @endpoints = endpoints end
def inspect
def inspect "\#<#{self.class} endpoints=#{@endpoints}>" end
def size
def size @endpoints.size end
def to_s
def to_s "composite:#{@endpoints.join(",")}" end
def with(**options)
def with(**options) self.class.new(endpoints.map{|endpoint| endpoint.with(**options)}, **@options.merge(options)) end