Skip to content

Commit

Permalink
Fix rubocop and rspec issues
Browse files Browse the repository at this point in the history
  • Loading branch information
alextwoods committed Jun 29, 2023
1 parent 7cbb76e commit bb13cc6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion codegen/projections/rails_json/lib/rails_json/client.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion codegen/projections/weather/lib/weather/client.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private Object removeRbExtension(String s) {

private void renderClassRuntimePlugins(RubyCodeWriter writer) {
if (context.getRuntimePlugins().isEmpty()) {
writer.write("@plugins = []");
writer.write("@plugins = PluginList.new");
} else {
writer.openBlock("@plugins = Hearth::PluginList.new([");
writer.write(
Expand Down
10 changes: 8 additions & 2 deletions hearth/lib/hearth/plugin_list.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# frozen_string_literal: true

module Hearth
# A list of plugins that can be applied to config. Plugins are callables
# that take one argument (config) and are called during client initialization
# or operation invocation to modify config.
class PluginList

def initialize(plugins = [])
unless plugins.respond_to?(:each)
raise ArgumentError, 'Plugins must be an enumerable'
end

@plugins = []
plugins.each { |p| add(p) }
end
Expand All @@ -14,14 +19,15 @@ def add(plugin)
raise ArgumentError,
'Plugin must be callable and take one argument (config)'
end

@plugins << plugin
end

def apply(config)
@plugins.each { |p| p.call(config) }
end

alias_method :<<, :add
alias :<< :add

private

Expand Down
4 changes: 2 additions & 2 deletions hearth/spec/hearth/plugin_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Hearth

context 'proc with incorrect number of arguments' do
let(:plugin) do
proc { }
proc {}
end

it 'raises an argument error' do
Expand All @@ -27,7 +27,7 @@ module Hearth

context 'non-callable object' do
let(:plugin) do
Class.new {}.new
Class.new.new
end

it 'raises an argument error' do
Expand Down

0 comments on commit bb13cc6

Please sign in to comment.