Class: Llmemory::LongTerm::GraphBased::Edge
- Inherits:
-
Struct
- Object
- Struct
- Llmemory::LongTerm::GraphBased::Edge
- Defined in:
- lib/llmemory/long_term/graph_based/edge.rb
Instance Attribute Summary collapse
-
#archived_at ⇒ Object
Returns the value of attribute archived_at.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#predicate ⇒ Object
Returns the value of attribute predicate.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#subject_id ⇒ Object
Returns the value of attribute subject_id.
-
#target_id ⇒ Object
Returns the value of attribute target_id.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
Class Method Summary collapse
Instance Method Summary collapse
- #archived? ⇒ Boolean
-
#provenance ⇒ Object
Lineage of this edge, stored within properties so it round-trips through every backend without a schema change.
- #to_h ⇒ Object
Instance Attribute Details
#archived_at ⇒ Object
Returns the value of attribute archived_at
6 7 8 |
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6 def archived_at @archived_at end |
#created_at ⇒ Object
Returns the value of attribute created_at
6 7 8 |
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id
6 7 8 |
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6 def id @id end |
#predicate ⇒ Object
Returns the value of attribute predicate
6 7 8 |
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6 def predicate @predicate end |
#properties ⇒ Object
Returns the value of attribute properties
6 7 8 |
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6 def properties @properties end |
#subject_id ⇒ Object
Returns the value of attribute subject_id
6 7 8 |
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6 def subject_id @subject_id end |
#target_id ⇒ Object
Returns the value of attribute target_id
6 7 8 |
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 6 def target_id @target_id end |
#user_id ⇒ Object
Returns the value of attribute 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
30 31 32 |
# File 'lib/llmemory/long_term/graph_based/edge.rb', line 30 def archived? !archived_at.nil? end |
#provenance ⇒ Object
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_h ⇒ Object
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 |