Skip to content

Commit

Permalink
More simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp committed Jun 19, 2024
1 parent 43ac2ab commit ee9a668
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions gems/aws-sdk-core/lib/seahorse/client/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ def build_config(plugins, options)
config.build!(options.merge(api: self.class.api))
end

# Builds a list of plugins from a configured list of plugins
def build_plugins(plugins)
plugins.map { |plugin| plugin.is_a?(Class) ? plugin.new : plugin }
end

# Gives each plugin the opportunity to register handlers for this client.
def build_handler_list(plugins)
plugins.inject(HandlerList.new) do |handlers, plugin|
Expand All @@ -82,7 +77,6 @@ def build_handler_list(plugins)

# Gives each plugin the opportunity to modify this client.
def after_initialize(plugins)
# TODO: handle plugins adding more plugins case?
plugins.reverse.each do |plugin|
plugin.after_initialize(self) if plugin.respond_to?(:after_initialize)
end
Expand Down Expand Up @@ -223,13 +217,13 @@ def before_initialize(plugins, options)
plugins.each { |plugin| queue.push(plugin) }
until queue.empty?
plugin = queue.pop
if plugin.respond_to?(:before_initialize)
plugins_before = options.fetch(:plugins, [])
plugin.before_initialize(self, options)
plugins_after = build_plugins(options.fetch(:plugins, []) - plugins_before)
# Plugins with before_initialize can add other plugins
plugins_after.each { |p| queue.push(p); plugins << p }
end
next unless plugin.respond_to?(:before_initialize)

plugins_before = options.fetch(:plugins, [])
plugin.before_initialize(self, options)
plugins_after = build_plugins(options.fetch(:plugins, []) - plugins_before)
# Plugins with before_initialize can add other plugins
plugins_after.each { |p| queue.push(p); plugins << p }
end
plugins
end
Expand Down

0 comments on commit ee9a668

Please sign in to comment.