Skip to content

Commit

Permalink
Fix Ruby 2.7 deprecation warn on Mounter#remove?
Browse files Browse the repository at this point in the history
On Ruby 2.7, with deprecation warnings enabled, the Mounter#remove? code
which handles string arguments to remove that we want to be treated as
false-y ("0" and "false") was throwing a deprecation warning:

"warning: deprecated Object#=~ is called on TrueClass; it always returns
nil"

This change fixes that warning by checking if the value is TrueClass
before running the regular expression.

Note that this does not change any behaviour since the presence check
was already handling the case that a false Boolean was passed, and the
case that a true Boolean was passed was already correctly not matching
the regular expression albeit with the deprecation warning.

This fix is the same as the one on the master branch commit
9a37fc9 by mshibuya.
  • Loading branch information
kaoru committed Dec 29, 2022
1 parent 56f39b2 commit 711d612
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/carrierwave/mounter.rb
Expand Up @@ -110,7 +110,7 @@ def blank?
end

def remove?
remove.present? && remove !~ /\A0|false$\z/
remove.present? && (remove == true || remove !~ /\A0|false$\z/)
end

def remove!
Expand Down

0 comments on commit 711d612

Please sign in to comment.