File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,15 +6,16 @@ module Client
66 module Features
77 class << self
88 def track ( *features , &block )
9- Thread . current [ :smithy_ruby_features ] ||= [ ]
10- Thread . current [ :smithy_ruby_features ] . concat ( features )
9+ Thread . current [ :smithy_ruby_features ] ||= Set . new
10+ added = features . map { | f | Thread . current [ :smithy_ruby_features ] . add? ( f ) }
1111 block . call
1212 ensure
13- Thread . current [ :smithy_ruby_features ] . pop ( features . size )
13+ features . each_with_index { | f , i | Thread . current [ :smithy_ruby_features ] . delete ( f ) if added [ i ] }
1414 end
1515
1616 def tracked
17- Thread . current [ :smithy_ruby_features ] || [ ]
17+ Thread . current [ :smithy_ruby_features ] || Set . new
18+ Thread . current [ :smithy_ruby_features ] . to_a
1819 end
1920 end
2021 end
Original file line number Diff line number Diff line change @@ -57,6 +57,17 @@ module Client
5757 end
5858 expect ( Features . tracked ) . to be_empty
5959 end
60+
61+ it 'does not track duplicate features' do
62+ Features . track ( 'A' , 'B' ) do
63+ expect ( Features . tracked ) . to eq ( %w[ A B ] )
64+ Features . track ( 'A' ) do
65+ expect ( Features . tracked ) . to eq ( %w[ A B ] )
66+ end
67+ expect ( Features . tracked ) . to eq ( %w[ A B ] )
68+ end
69+ expect ( Features . tracked ) . to be_empty
70+ end
6071 end
6172 end
6273end
Original file line number Diff line number Diff line change @@ -161,8 +161,7 @@ class Client < Smithy::Client::Base
161161 # @option options [Boolean] :stub_responses
162162 # When `true`, the client will return stubbed responses instead of networking requests.
163163 # By default fake responses are generated and returned. You can specify the response data
164- # to return or errors to raise by calling {Stubs#stub_responses}.
165- # @see Stubs
164+ # to return or errors to raise by calling {Smithy::Client::Stubs#stub_responses}.
166165 # @option options [String] :user_agent_suffix
167166 # An optional string that is appended to the User-Agent header.
168167 # The default User-Agent includes the smithy-client version,
Original file line number Diff line number Diff line change @@ -161,8 +161,7 @@ class Client < Smithy::Client::Base
161161 # @option options [Boolean] :stub_responses
162162 # When `true`, the client will return stubbed responses instead of networking requests.
163163 # By default fake responses are generated and returned. You can specify the response data
164- # to return or errors to raise by calling {Stubs#stub_responses}.
165- # @see Stubs
164+ # to return or errors to raise by calling {Smithy::Client::Stubs#stub_responses}.
166165 # @option options [String] :user_agent_suffix
167166 # An optional string that is appended to the User-Agent header.
168167 # The default User-Agent includes the smithy-client version,
You can’t perform that action at this time.
0 commit comments