module RubyLLM::Browser::Immutable

Copies host-owned input before freezing it. Never freezes the caller’s objects.

Public Instance Methods

copy(value) click to toggle source
# File lib/ruby_llm/browser/immutable.rb, line 9
def copy(value)
  case value
  when Hash then value.to_h { |key, nested| [ copy(key), copy(nested) ] }.freeze
  when Array then value.map { |nested| copy(nested) }.freeze
  when String, Time then value.dup.freeze
  else value
  end
end