Module: Faulty::Deprecation

Defined in:
lib/faulty/deprecation.rb

Overview

Support deprecating Faulty features

Class Method Summary collapse

Class Method Details

.deprecate(subject, note: nil, sunset: nil) ⇒ Object

Raises:



25
26
27
28
29
30
31
32
33
34
# File 'lib/faulty/deprecation.rb', line 25

def deprecate(subject, note: nil, sunset: nil)
  return if @silence

  message = "#{subject} is deprecated"
  message += " and will be removed in #{sunset}" if sunset
  message += " (#{note})" if note
  raise DeprecationError, message if @raise_errors

  Kernel.warn("DEPRECATION: #{message}")
end

.method(klass, name, note: nil, sunset: nil) ⇒ Object



20
21
22
# File 'lib/faulty/deprecation.rb', line 20

def method(klass, name, note: nil, sunset: nil)
  deprecate("#{klass}##{name}", note: note, sunset: sunset)
end

.raise_errors!(enabled = true) ⇒ Object

Call to raise errors instead of logging warnings for Faulty deprecations



8
9
10
# File 'lib/faulty/deprecation.rb', line 8

def raise_errors!(enabled = true) # rubocop:disable Style/OptionalBooleanParameter
  @raise_errors = (enabled == true)
end

.silencedObject



12
13
14
15
16
17
# File 'lib/faulty/deprecation.rb', line 12

def silenced
  @silence = true
  yield
ensure
  @silence = false
end