Class: Datadog::SymbolDatabase::Symbol Private
- Inherits:
-
Object
- Object
- Datadog::SymbolDatabase::Symbol
- Defined in:
- lib/datadog/symbol_database/symbol.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents a symbol (variable, parameter, field, constant) within a scope.
Symbols are the actual identifiers extracted from Ruby code:
- Instance variables (@var) - FIELD type
- Class variables (@@var) - STATIC_FIELD type
- Constants (CONST) - STATIC_FIELD type
- Method parameters (arg) - ARG type
- Local variables (var) - LOCAL type (not yet implemented)
Created by: Extractor (during class/method introspection) Contained in: Scope objects (symbols array) Serialized to: JSON via to_h/to_json
Instance Attribute Summary collapse
- #language_specifics ⇒ Object readonly private
- #line ⇒ Object readonly private
- #name ⇒ Object readonly private
- #symbol_type ⇒ Object readonly private
- #type ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(symbol_type:, name:, line:, type: nil, language_specifics: nil) ⇒ Symbol
constructor
private
Initialize a new Symbol.
-
#to_h ⇒ Hash
private
Convert symbol to Hash for JSON serialization.
-
#to_json(_state = nil) ⇒ String
private
Serialize symbol to JSON.
Constructor Details
#initialize(symbol_type:, name:, line:, type: nil, language_specifics: nil) ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a new Symbol
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/datadog/symbol_database/symbol.rb', line 30 def initialize( symbol_type:, name:, line:, type: nil, language_specifics: nil ) @symbol_type = symbol_type @name = name @line = line @type = type @language_specifics = language_specifics end |
Instance Attribute Details
#language_specifics ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'lib/datadog/symbol_database/symbol.rb', line 22 def language_specifics @language_specifics end |
#line ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'lib/datadog/symbol_database/symbol.rb', line 22 def line @line end |
#name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'lib/datadog/symbol_database/symbol.rb', line 22 def name @name end |
#symbol_type ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'lib/datadog/symbol_database/symbol.rb', line 22 def symbol_type @symbol_type end |
#type ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'lib/datadog/symbol_database/symbol.rb', line 22 def type @type end |
Instance Method Details
#to_h ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Convert symbol to Hash for JSON serialization.
The type key is always present per the symdb JSON schema — emit nil
when the type cannot be determined (the common case in Ruby since
parameters and instance variables carry no declared type).
language_specifics is omitted when nil to reduce payload size.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/datadog/symbol_database/symbol.rb', line 50 def to_h # @type var h: Hash[::Symbol, untyped] h = { symbol_type: symbol_type, name: name, line: line, type: type, } h[:language_specifics] = language_specifics if language_specifics h end |
#to_json(_state = nil) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Serialize symbol to JSON.
64 65 66 |
# File 'lib/datadog/symbol_database/symbol.rb', line 64 def to_json(_state = nil) JSON.generate(to_h) end |