Class: WarningSigns::Deprecation
- Inherits:
-
Object
- Object
- WarningSigns::Deprecation
- Defined in:
- lib/warning_signs/deprecation.rb
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
Returns the value of attribute backtrace.
-
#category ⇒ Object
Returns the value of attribute category.
-
#message ⇒ Object
Returns the value of attribute message.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
-
#behaviors ⇒ Object
force raise to be the last element if it is present.
- #handler ⇒ Object
-
#initialize(message, source:, category: nil, backtrace: []) ⇒ Deprecation
constructor
A new instance of Deprecation.
- #invoke ⇒ Object
- #message_formatter_for(behavior) ⇒ Object
Constructor Details
#initialize(message, source:, category: nil, backtrace: []) ⇒ Deprecation
Returns a new instance of Deprecation.
5 6 7 8 9 10 |
# File 'lib/warning_signs/deprecation.rb', line 5 def initialize(, source:, category: nil, backtrace: []) @message = @source = source.to_s.downcase.inquiry @category = category @backtrace = backtrace || [] end |
Instance Attribute Details
#backtrace ⇒ Object
Returns the value of attribute backtrace.
3 4 5 |
# File 'lib/warning_signs/deprecation.rb', line 3 def backtrace @backtrace end |
#category ⇒ Object
Returns the value of attribute category.
3 4 5 |
# File 'lib/warning_signs/deprecation.rb', line 3 def category @category end |
#message ⇒ Object
Returns the value of attribute message.
3 4 5 |
# File 'lib/warning_signs/deprecation.rb', line 3 def @message end |
#source ⇒ Object
Returns the value of attribute source.
3 4 5 |
# File 'lib/warning_signs/deprecation.rb', line 3 def source @source end |
Instance Method Details
#behaviors ⇒ Object
force raise to be the last element if it is present
21 22 23 24 25 |
# File 'lib/warning_signs/deprecation.rb', line 21 def behaviors result = (handler&.environment&.behaviors || []).inquiry return result unless result.raise? (result - ["raise"]) << "raise" end |
#handler ⇒ Object
12 13 14 |
# File 'lib/warning_signs/deprecation.rb', line 12 def handler World.instance.handler_for(self) end |
#invoke ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/warning_signs/deprecation.rb', line 27 def invoke behaviors.each do |behavior_type| Behavior::Base.for( behavior_type, , backtrace, (behavior_type) ).emit end end |
#message_formatter_for(behavior) ⇒ Object
16 17 18 |
# File 'lib/warning_signs/deprecation.rb', line 16 def (behavior) handler.(behavior) end |