Sha256: 7ef659a35e4b7272fb638fed76275ba86a4fd2f30aaa185008b8303b551b74cd
Contents?: true
Size: 750 Bytes
Versions: 12
Compression:
Stored size: 750 Bytes
Contents
# frozen_string_literal: true # Released under the MIT License. # Copyright, 2022-2023, by Samuel Williams. require_relative 'endpoint' module Async module IO class CompositeEndpoint < Endpoint def initialize(endpoints, **options) super(**options) @endpoints = endpoints end def each(&block) @endpoints.each(&block) end def connect(&block) error = nil @endpoints.each do |endpoint| begin return endpoint.connect(&block) rescue => error end end raise error end def bind(&block) @endpoints.map(&:bind) end end class Endpoint def self.composite(*endpoints, **options) CompositeEndpoint.new(endpoints, **options) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems