Method: Anthropic::Internal::Type::BaseModel#initialize

Defined in:
lib/anthropic/internal/type/base_model.rb

#initialize(data = {}) ⇒ BaseModel

Create a new instance of a model.

Parameters:

  • data (Hash{Symbol=>Object}, self) (defaults to: {})


475
476
477
478
479
480
481
482
483
484
485
486
# File 'lib/anthropic/internal/type/base_model.rb', line 475

def initialize(data = {})
  @data = {}
  @coerced = {}
  Anthropic::Internal::Util.coerce_hash!(data).each do
    if self.class.known_fields.key?(_1)
      public_send(:"#{_1}=", _2)
    else
      @data.store(_1, _2)
      @coerced.store(_1, false)
    end
  end
end