Class: HTM::Models::RobotNode

Inherits:
Object
  • Object
show all
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

Instance Method Details

#deleted?Boolean

Check if entry is soft-deleted

Returns:

  • (Boolean)

    true if deleted_at is set



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

Returns:



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

Returns:

  • (Boolean)

    true if restored successfully



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

Returns:

  • (Boolean)

    true if soft deleted successfully



68
69
70
71
# File 'lib/htm/models/robot_node.rb', line 68

def soft_delete!
  update(deleted_at: Time.now)
  true
end

#validateObject

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

Returns:

  • (Boolean)

    true if working_memory is set



94
95
96
# File 'lib/htm/models/robot_node.rb', line 94

def working_memory?
  !!working_memory
end