Module: Uncruft::Warning

Defined in:
lib/uncruft/warning.rb

Constant Summary collapse

DEPRECATION_PATTERN =
/(deprecation|deprecated)/i.freeze

Instance Method Summary collapse

Instance Method Details

#warn(str, *args, **kwargs) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/uncruft/warning.rb', line 5

def warn(str, *args, **kwargs)
  if str =~ DEPRECATION_PATTERN # rubocop:disable Performance/RegexpMatch
    message = strip_caller_info(str, caller_locations(1..1).first).strip
    ActiveSupport::Deprecation.warn(message)
  elsif RUBY_VERSION < '2.7' && kwargs.empty?
    super(str, *args)
  else
    super
  end
end