Skip to content

Commit

Permalink
adds exclamation to ensure_regular_arity
Browse files Browse the repository at this point in the history
...since that method raises or doesn't.
  • Loading branch information
joelhelbling committed Aug 23, 2023
1 parent eec8662 commit 5e8ca16
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/shifty/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def source_worker(argument = nil, &block)
def relay_worker(options = {}, &block)
options[:tags] ||= []
options[:tags] << :relay
ensure_regular_arity(block)
ensure_regular_arity!(block)

Worker.new(options) do |value|
value && block.call(value)
Expand All @@ -33,7 +33,7 @@ def side_worker(options = {}, &block)
options[:tags] ||= []
options[:tags] << :side_effect
mode = options[:mode] || :normal
ensure_regular_arity(block)
ensure_regular_arity!(block)

Worker.new(options) do |value|
value.tap do |v|
Expand Down Expand Up @@ -70,7 +70,7 @@ def batch_worker(options = {}, &block)
options[:tags] << :batch
options[:gathering] ||= 1

ensure_regular_arity(block) if block
ensure_regular_arity!(block) if block
batch_full = block ||
proc { |_, batch| batch.size >= options[:gathering] }

Expand All @@ -93,7 +93,7 @@ def batch_worker(options = {}, &block)
def splitter_worker(options = {}, &block)
options[:tags] ||= []
options[:tags] << :splitter
ensure_regular_arity(block)
ensure_regular_arity!(block)

Worker.new(options) do |value|
if value.nil?
Expand Down Expand Up @@ -145,7 +145,7 @@ def ensure_callable!(callable)
end
end

def ensure_regular_arity(block)
def ensure_regular_arity!(block)
if block.arity != 1
throw_with \
"Worker must accept exactly one argument (arity == 1)"
Expand All @@ -156,7 +156,7 @@ def ensure_regular_arity(block)
def ensure_correct_arity_for!(argument, block)
return unless block
if argument
ensure_regular_arity(block)
ensure_regular_arity!(block)
elsif block.arity > 0
throw_with \
"Source worker cannot accept any arguments (arity == 0)"
Expand Down

0 comments on commit 5e8ca16

Please sign in to comment.