Module: Legion::LLM::CompatWarning

Defined in:
lib/legion/llm/compat.rb

Class Method Summary collapse

Class Method Details

.warn_once(old_name, new_name) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/legion/llm/compat.rb', line 6

def self.warn_once(old_name, new_name)
  @warned ||= {}
  return if @warned[old_name]

  @warned[old_name] = true
  location = caller_locations(2, 1)&.first
  msg = "[DEPRECATION] #{old_name} is deprecated, use #{new_name} instead"
  msg += " (called from #{location})" if location
  if defined?(Legion::Logging)
    Legion::Logging.warn(msg)
  else
    warn msg
  end
end