Skip to content

Commit a134eeb

Browse files
authored
Invert conditional
This avoid a method call and also is easier to read.
1 parent 83ce6e3 commit a134eeb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

activesupport/lib/active_support/core_ext/object/with_options.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ class Object
9292
def with_options(options, &block)
9393
option_merger = ActiveSupport::OptionMerger.new(self, options)
9494

95-
if block.nil?
96-
option_merger
97-
else
95+
if block
9896
block.arity.zero? ? option_merger.instance_eval(&block) : block.call(option_merger)
97+
else
98+
option_merger
9999
end
100100
end
101101
end

0 commit comments

Comments
 (0)