Module: Adyen::Deprecation
- Defined in:
- lib/adyen/deprecation.rb
Overview
Helper module for emitting deprecation warnings for deprecated API methods.
Class Method Summary collapse
-
.silenced=(value) ⇒ Object
Set to true to silence all Adyen deprecation warnings, regardless of Warning.
-
.silenced? ⇒ Boolean
True when deprecation warnings are silenced, either via the attribute or, when the attribute was never set, via the ADYEN_SILENCE_DEPRECATIONS environment variable ("1", "true" or "yes", case-insensitive).
-
.warn(method_name, since: nil, message: nil) ⇒ Object
Emits a deprecation warning for a deprecated method.
Class Method Details
.silenced=(value) ⇒ Object
Set to true to silence all Adyen deprecation warnings, regardless of Warning. Explicitly setting this attribute (true or false) overrides the ADYEN_SILENCE_DEPRECATIONS environment variable.
7 8 9 |
# File 'lib/adyen/deprecation.rb', line 7 def self.silenced=(value) @silenced = value end |
.silenced? ⇒ Boolean
True when deprecation warnings are silenced, either via the attribute or, when the attribute was never set, via the ADYEN_SILENCE_DEPRECATIONS environment variable ("1", "true" or "yes", case-insensitive).
14 15 16 17 18 |
# File 'lib/adyen/deprecation.rb', line 14 def self.silenced? return @silenced unless @silenced.nil? %w[1 true yes].include?(ENV.fetch('ADYEN_SILENCE_DEPRECATIONS', '').downcase) end |
.warn(method_name, since: nil, message: nil) ⇒ Object
Emits a deprecation warning for a deprecated method.
25 26 27 28 29 30 31 32 |
# File 'lib/adyen/deprecation.rb', line 25 def self.warn(method_name, since: nil, message: nil) return if silenced? text = "[DEPRECATED] `#{method_name}` is deprecated" text += " since #{since}" if since text += ". #{}" if Kernel.warn(text, category: :deprecated, uplevel: 2) end |