Module: RubyLLM::Agents::Deprecations
- Defined in:
- lib/ruby_llm/agents/core/deprecations.rb
Overview
Manages deprecation warnings with configurable behavior
Provides a centralized mechanism for deprecation warnings that can be configured to raise exceptions in test environments or emit warnings in production.
Defined Under Namespace
Classes: DeprecationError
Class Attribute Summary collapse
-
.raise_on_deprecation ⇒ Boolean
Whether to raise exceptions instead of warnings.
-
.silenced ⇒ Boolean
Whether to silence all deprecation warnings.
Class Method Summary collapse
-
.silence { ... } ⇒ Object
Temporarily silence deprecation warnings within a block.
-
.warn(message, callstack = caller) ⇒ void
Emits a deprecation warning or raises an error.
Class Attribute Details
.raise_on_deprecation ⇒ Boolean
Returns Whether to raise exceptions instead of warnings.
27 28 29 |
# File 'lib/ruby_llm/agents/core/deprecations.rb', line 27 def raise_on_deprecation @raise_on_deprecation end |
.silenced ⇒ Boolean
Returns Whether to silence all deprecation warnings.
31 32 33 |
# File 'lib/ruby_llm/agents/core/deprecations.rb', line 31 def silenced @silenced end |
Class Method Details
.silence { ... } ⇒ Object
Temporarily silence deprecation warnings within a block
63 64 65 66 67 68 69 |
# File 'lib/ruby_llm/agents/core/deprecations.rb', line 63 def silence old_silenced = silenced self.silenced = true yield ensure self.silenced = old_silenced end |
.warn(message, callstack = caller) ⇒ void
This method returns an undefined value.
Emits a deprecation warning or raises an error
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ruby_llm/agents/core/deprecations.rb', line 39 def warn(, callstack = caller) return if silenced = "[RubyLLM::Agents DEPRECATION] #{}" if raise_on_deprecation raise DeprecationError, elsif defined?(Rails) && Rails.respond_to?(:application) && Rails.application # Use Rails deprecator if available (Rails 7.1+) if Rails.application.respond_to?(:deprecators) Rails.application.deprecators[:ruby_llm_agents]&.warn(, callstack) || ::Kernel.warn("#{}\n #{callstack.first}") else ::Kernel.warn("#{}\n #{callstack.first}") end else ::Kernel.warn("#{}\n #{callstack.first}") end end |