Class: WarningSigns::World
- Inherits:
-
Object
- Object
- WarningSigns::World
- Includes:
- Singleton
- Defined in:
- lib/warning_signs/world.rb
Instance Attribute Summary collapse
-
#handlers ⇒ Object
Returns the value of attribute handlers.
Class Method Summary collapse
Instance Method Summary collapse
- #clear ⇒ Object
- #enabled_for_rails? ⇒ Boolean
- #enabled_for_ruby? ⇒ Boolean
- #handler_for(deprecation) ⇒ Object
-
#initialize ⇒ World
constructor
A new instance of World.
- #one_time_set_up ⇒ Object
- #rails_set_up ⇒ Object
- #ruby_set_up ⇒ Object
Constructor Details
#initialize ⇒ World
Returns a new instance of World.
17 18 19 20 |
# File 'lib/warning_signs/world.rb', line 17 def initialize @initialized = false clear end |
Instance Attribute Details
#handlers ⇒ Object
Returns the value of attribute handlers.
4 5 6 |
# File 'lib/warning_signs/world.rb', line 4 def handlers @handlers end |
Class Method Details
.from_file(filename) ⇒ Object
6 7 8 |
# File 'lib/warning_signs/world.rb', line 6 def self.from_file(filename) from_hash(YAML.load_file(filename)) end |
Instance Method Details
#clear ⇒ Object
26 27 28 |
# File 'lib/warning_signs/world.rb', line 26 def clear @handlers = [] end |
#enabled_for_rails? ⇒ Boolean
30 31 32 |
# File 'lib/warning_signs/world.rb', line 30 def enabled_for_rails? handlers.any? { !_1.enabled_for_rails? } end |
#enabled_for_ruby? ⇒ Boolean
34 35 36 |
# File 'lib/warning_signs/world.rb', line 34 def enabled_for_ruby? handlers.any? { !_1.enabled_for_ruby? } end |
#handler_for(deprecation) ⇒ Object
22 23 24 |
# File 'lib/warning_signs/world.rb', line 22 def handler_for(deprecation) handlers.find { _1.match?(deprecation) } end |
#one_time_set_up ⇒ Object
38 39 40 41 42 43 |
# File 'lib/warning_signs/world.rb', line 38 def one_time_set_up return if @initialized ruby_set_up rails_set_up @initialized = true end |
#rails_set_up ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/warning_signs/world.rb', line 50 def rails_set_up if ActiveSupport.version >= Gem::Version.new("7.1.0") Rails.application.deprecators.behavior = :notify else ActiveSupport::Deprecation.behavior = :notify end end |
#ruby_set_up ⇒ Object
45 46 47 48 |
# File 'lib/warning_signs/world.rb', line 45 def ruby_set_up Warning[:deprecated] = true Warning.extend(WarningSigns::RubyDeprecationCatcher) end |