Skip to content

Commit

Permalink
Expose size and internal endpoints for composite endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jul 15, 2024
1 parent 2c442ae commit b16bbed
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/io/endpoint/composite_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ def initialize(endpoints, **options)
@endpoints = endpoints
end

attr :endpoints

# The number of endpoints in the composite endpoint.
def size
@endpoints.size
end

def each(&block)
@endpoints.each do |endpoint|
endpoint.each(&block)
Expand Down
12 changes: 12 additions & 0 deletions test/io/endpoint/composite_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,16 @@
servers&.each(&:close)
thread&.join
end

with '#size' do
it "returns the number of endpoints" do
expect(endpoint.size).to be == 1
end
end

with '#endpoints' do
it "returns the endpoints" do
expect(endpoint.endpoints).to be == [internal_endpoint]
end
end
end

0 comments on commit b16bbed

Please sign in to comment.