Class: ClaudeAgentSDK::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_agent_sdk/types.rb

Overview

Base class for all types.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Type

Returns a new instance of Type.



75
76
77
78
# File 'lib/claude_agent_sdk/types.rb', line 75

def initialize(attributes = {})
  assign_attributes(attributes) if attributes
  super()
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object (private)

Allow camelCase attribute access



96
97
98
99
100
101
102
103
104
# File 'lib/claude_agent_sdk/types.rb', line 96

def method_missing(method_name, ...)
  normalized = normalize_name(method_name)

  if normalized != method_name.to_s && respond_to?(normalized)
    public_send(normalized, ...)
  else
    super
  end
end

Class Method Details

.from_hash(hash) ⇒ Object



69
70
71
72
73
# File 'lib/claude_agent_sdk/types.rb', line 69

def self.from_hash(hash)
  return unless hash.is_a?(Hash)

  new(hash)
end

.wrap(object) ⇒ Object



62
63
64
65
66
67
# File 'lib/claude_agent_sdk/types.rb', line 62

def self.wrap(object)
  return object if object.is_a?(self)
  return nil if object.nil?

  new(object)
end

Instance Method Details

#[](name) ⇒ Object



80
81
82
# File 'lib/claude_agent_sdk/types.rb', line 80

def [](name)
  read_attribute(name)
end

#[]=(name, value) ⇒ Object



84
85
86
# File 'lib/claude_agent_sdk/types.rb', line 84

def []=(name, value)
  assign_attribute(name, value)
end

#to_hObject

Subclasses should override this to return a hash representation of the object.



89
90
91
# File 'lib/claude_agent_sdk/types.rb', line 89

def to_h
  {}
end