Class: HTM::Models::RobotNode
- Inherits:
-
Object
- Object
- HTM::Models::RobotNode
- Defined in:
- lib/htm/models/robot_node.rb
Overview
RobotNode Join Model - Links robots to nodes (many-to-many)
This model represents the relationship between a robot and a node, tracking when and how many times a robot has “remembered” a piece of content.
Instance Method Summary collapse
-
#deleted? ⇒ Boolean
Check if entry is soft-deleted.
-
#record_remember! ⇒ RobotNode
Record that a robot remembered this content again.
-
#restore! ⇒ Boolean
Restore a soft-deleted entry.
-
#soft_delete! ⇒ Boolean
Soft delete - mark as deleted without removing from database.
-
#validate ⇒ Object
Validations.
-
#working_memory? ⇒ Boolean
Check if this node is in working memory.
Instance Method Details
#deleted? ⇒ Boolean
Check if entry is soft-deleted
86 87 88 |
# File 'lib/htm/models/robot_node.rb', line 86 def deleted? !deleted_at.nil? end |
#record_remember! ⇒ RobotNode
Record that a robot remembered this content again
102 103 104 105 106 107 |
# File 'lib/htm/models/robot_node.rb', line 102 def record_remember! self.remember_count += 1 self.last_remembered_at = Time.now save self end |
#restore! ⇒ Boolean
Restore a soft-deleted entry
77 78 79 80 |
# File 'lib/htm/models/robot_node.rb', line 77 def restore! update(deleted_at: nil) true end |
#soft_delete! ⇒ Boolean
Soft delete - mark as deleted without removing from database
68 69 70 71 |
# File 'lib/htm/models/robot_node.rb', line 68 def soft_delete! update(deleted_at: Time.now) true end |
#validate ⇒ Object
Validations
20 21 22 23 24 |
# File 'lib/htm/models/robot_node.rb', line 20 def validate super validates_presence %i[robot_id node_id] validates_unique %i[robot_id node_id], message: 'already linked to this node' end |
#working_memory? ⇒ Boolean
Check if this node is in working memory
94 95 96 |
# File 'lib/htm/models/robot_node.rb', line 94 def working_memory? !!working_memory end |