Class: Llmemory::LongTerm::GraphBased::Edge

Inherits:
Struct
  • Object
show all
Defined in:
lib/llmemory/long_term/graph_based/edge.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#archived_atObject

Returns the value of attribute archived_at

Returns:

  • (Object)

    the current value of archived_at



6
7
8
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6

def archived_at
  @archived_at
end

#created_atObject

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



6
7
8
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6

def created_at
  @created_at
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



6
7
8
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6

def id
  @id
end

#predicateObject

Returns the value of attribute predicate

Returns:

  • (Object)

    the current value of predicate



6
7
8
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6

def predicate
  @predicate
end

#propertiesObject

Returns the value of attribute properties

Returns:

  • (Object)

    the current value of properties



6
7
8
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6

def properties
  @properties
end

#subject_idObject

Returns the value of attribute subject_id

Returns:

  • (Object)

    the current value of subject_id



6
7
8
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6

def subject_id
  @subject_id
end

#target_idObject

Returns the value of attribute target_id

Returns:

  • (Object)

    the current value of target_id



6
7
8
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6

def target_id
  @target_id
end

#user_idObject

Returns the value of attribute user_id

Returns:

  • (Object)

    the current value of user_id



6
7
8
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6

def user_id
  @user_id
end

Class Method Details

.from_h(hash) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 17

def self.from_h(hash)
  new(
    id: hash[:id] || hash["id"],
    user_id: hash[:user_id] || hash["user_id"],
    subject_id: hash[:subject_id] || hash["subject_id"],
    predicate: (hash[:predicate] || hash["predicate"]).to_s,
    target_id: hash[:object_id] || hash["object_id"],
    properties: hash[:properties] || hash["properties"] || {},
    created_at: hash[:created_at] || hash["created_at"],
    archived_at: hash[:archived_at] || hash["archived_at"]
  )
end

Instance Method Details

#archived?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 30

def archived?
  !archived_at.nil?
end

#provenanceObject

Lineage of this edge, stored within properties so it round-trips through every backend without a schema change. See Llmemory::Provenance.



36
37
38
39
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 36

def provenance
  props = properties || {}
  props[:provenance] || props["provenance"]
end

#to_hObject



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 41

def to_h
  {
    id: id,
    user_id: user_id,
    subject_id: subject_id,
    predicate: predicate,
    object_id: target_id,
    properties: properties || {},
    created_at: created_at,
    archived_at: archived_at
  }
end