Module: Plurimath::Deprecation
- Defined in:
- lib/plurimath/deprecation.rb
Constant Summary collapse
- BEHAVIORS =
%i[collect raise silence].freeze
- DEFAULT_BEHAVIOR =
:collect
Class Method Summary collapse
- .behavior ⇒ Object
- .behavior=(behavior) ⇒ Object
- .clear! ⇒ Object
- .notices ⇒ Object
- .warn(feature:, message: nil, replacement: nil, since: nil, remove_in: nil) ⇒ Object
Class Method Details
.behavior ⇒ Object
31 32 33 |
# File 'lib/plurimath/deprecation.rb', line 31 def behavior @behavior ||= DEFAULT_BEHAVIOR end |
.behavior=(behavior) ⇒ Object
35 36 37 |
# File 'lib/plurimath/deprecation.rb', line 35 def behavior=(behavior) @behavior = validate_behavior(behavior) end |
.clear! ⇒ Object
43 44 45 |
# File 'lib/plurimath/deprecation.rb', line 43 def clear! @emitted_features = {} end |
.notices ⇒ Object
39 40 41 |
# File 'lib/plurimath/deprecation.rb', line 39 def notices emitted_features.values end |
.warn(feature:, message: nil, replacement: nil, since: nil, remove_in: nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/plurimath/deprecation.rb', line 9 def warn(feature:, message: nil, replacement: nil, since: nil, remove_in: nil) feature = validate_feature(feature) return if behavior == :collect && emitted_features[feature] notice = build_notice( feature: feature, message: , replacement: replacement, since: since, remove_in: remove_in, ) case behavior when :silence nil when :raise raise notice when :collect emitted_features[feature] = notice end end |