Class: Agent::SessionContext::Item

Inherits:
Data
  • Object
show all
Defined in:
lib/agent/session_context/item.rb

Constant Summary collapse

EVIDENCE_VALUES =
%i[observed explicit inferred].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind:, label:, evidence:, source_refs:, detail: nil, attributes: {}) ⇒ Item

Returns a new instance of Item.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/agent/session_context/item.rb', line 8

def initialize(kind:, label:, evidence:, source_refs:, detail: nil, attributes: {})
  unless EVIDENCE_VALUES.include?(evidence)
    raise ArgumentError,
          "evidence must be one of: #{EVIDENCE_VALUES.join(", ")}"
  end

  super(
    kind: kind.to_sym,
    label: normalize_string(label, :label),
    detail: normalize_optional_string(detail, :detail),
    evidence: evidence,
    source_refs: ImmutableValue.copy(Array(source_refs)),
    attributes: normalize_attributes(attributes)
  )
end

Instance Attribute Details

#attributes ⇒ Object (readonly)

Returns the value of attribute attributes

Returns:

  • (Object) —

    the current value of attributes



5
6
7
# File 'lib/agent/session_context/item.rb', line 5

def attributes
  @attributes
end

#detail ⇒ Object (readonly)

Returns the value of attribute detail

Returns:

  • (Object) —

    the current value of detail



5
6
7
# File 'lib/agent/session_context/item.rb', line 5

def detail
  @detail
end

#evidence ⇒ Object (readonly)

Returns the value of attribute evidence

Returns:

  • (Object) —

    the current value of evidence



5
6
7
# File 'lib/agent/session_context/item.rb', line 5

def evidence
  @evidence
end

#kind ⇒ Object (readonly)

Returns the value of attribute kind

Returns:

  • (Object) —

    the current value of kind



5
6
7
# File 'lib/agent/session_context/item.rb', line 5

def kind
  @kind
end

#label ⇒ Object (readonly)

Returns the value of attribute label

Returns:

  • (Object) —

    the current value of label



5
6
7
# File 'lib/agent/session_context/item.rb', line 5

def label
  @label
end

#source_refs ⇒ Object (readonly)

Returns the value of attribute source_refs

Returns:

  • (Object) —

    the current value of source_refs



5
6
7
# File 'lib/agent/session_context/item.rb', line 5

def source_refs
  @source_refs
end