Skip to content

Commit 3505ee0

Browse files
Merge pull request #211 from datastax/RUBY-267
RUBY-267 - Support iterating execution profiles.
2 parents 8bc43b8 + 234fc37 commit 3505ee0

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

lib/cassandra/cluster.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,23 @@ def execution_profile(name)
167167
@profile_manager.profiles[name]
168168
end
169169

170-
# @return [Hash<String, Cassandra::Execution::Profile>] the collection of execution profiles
171-
def execution_profiles
172-
# Return a dup of the hash to prevent the user from adding/removing profiles from the profile-manager.
173-
@profile_manager.profiles.dup
170+
# Yield or enumerate each execution profile defined in this cluster
171+
# @overload each_execution_profile
172+
# @yieldparam name [String, Symbol] name of current profile
173+
# @yieldparam profile [Cassandra::Execution::Profile] current profile
174+
# @return [Cassandra::Cluster] self
175+
# @overload each_execution_profile
176+
# @return [Hash<String, Cassandra::Execution::Profile>] a hash of profiles keyed on name
177+
def each_execution_profile(&block)
178+
if block_given?
179+
@profile_manager.profiles.each_pair(&block)
180+
self
181+
else
182+
# Return a dup of the hash to prevent the user from adding/removing profiles from the profile-manager.
183+
@profile_manager.profiles.dup
184+
end
174185
end
186+
alias execution_profiles each_execution_profile
175187

176188
# @!method refresh_schema_async
177189
# Trigger an asynchronous schema metadata refresh

0 commit comments

Comments
 (0)