Class: RubynCode::Memory::MemoryRecord

Inherits:
Data
  • Object
show all
Defined in:
lib/rubyn_code/memory/models.rb

Overview

Immutable value object representing a single memory record.

Tiers control retention and decay:

- "short"  : ephemeral, decays quickly, session-scoped
- "medium" : moderate retention, project-scoped
- "long"   : persistent, rarely decays

Categories classify the kind of knowledge stored:

- "code_pattern"        : recurring code patterns or idioms
- "user_preference"     : how the user likes things done
- "project_convention"  : project-specific conventions
- "error_resolution"    : known error/fix pairs
- "decision"            : architectural or design decisions

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_countObject (readonly)

Returns the value of attribute access_count

Returns:

  • (Object)

    the current value of access_count



21
22
23
# File 'lib/rubyn_code/memory/models.rb', line 21

def access_count
  @access_count
end

#categoryObject (readonly)

Returns the value of attribute category

Returns:

  • (Object)

    the current value of category



21
22
23
# File 'lib/rubyn_code/memory/models.rb', line 21

def category
  @category
end

#contentObject (readonly)

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



21
22
23
# File 'lib/rubyn_code/memory/models.rb', line 21

def content
  @content
end

#created_atObject (readonly)

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



21
22
23
# File 'lib/rubyn_code/memory/models.rb', line 21

def created_at
  @created_at
end

#expires_atObject (readonly)

Returns the value of attribute expires_at

Returns:

  • (Object)

    the current value of expires_at



21
22
23
# File 'lib/rubyn_code/memory/models.rb', line 21

def expires_at
  @expires_at
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



21
22
23
# File 'lib/rubyn_code/memory/models.rb', line 21

def id
  @id
end

#last_accessed_atObject (readonly)

Returns the value of attribute last_accessed_at

Returns:

  • (Object)

    the current value of last_accessed_at



21
22
23
# File 'lib/rubyn_code/memory/models.rb', line 21

def last_accessed_at
  @last_accessed_at
end

#metadataObject (readonly)

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



21
22
23
# File 'lib/rubyn_code/memory/models.rb', line 21

def 
  @metadata
end

#project_pathObject (readonly)

Returns the value of attribute project_path

Returns:

  • (Object)

    the current value of project_path



21
22
23
# File 'lib/rubyn_code/memory/models.rb', line 21

def project_path
  @project_path
end

#relevance_scoreObject (readonly)

Returns the value of attribute relevance_score

Returns:

  • (Object)

    the current value of relevance_score



21
22
23
# File 'lib/rubyn_code/memory/models.rb', line 21

def relevance_score
  @relevance_score
end

#tierObject (readonly)

Returns the value of attribute tier

Returns:

  • (Object)

    the current value of tier



21
22
23
# File 'lib/rubyn_code/memory/models.rb', line 21

def tier
  @tier
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


27
28
29
30
31
32
33
# File 'lib/rubyn_code/memory/models.rb', line 27

def expired?
  return false if expires_at.nil?

  Time.parse(expires_at.to_s) < Time.now
rescue ArgumentError
  false
end

#long?Boolean

Returns:

  • (Boolean)


42
# File 'lib/rubyn_code/memory/models.rb', line 42

def long? = tier == 'long'

#medium?Boolean

Returns:

  • (Boolean)


39
# File 'lib/rubyn_code/memory/models.rb', line 39

def medium? = tier == 'medium'

#short?Boolean

Returns:

  • (Boolean)


36
# File 'lib/rubyn_code/memory/models.rb', line 36

def short? = tier == 'short'

#to_hHash

Returns:

  • (Hash)


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rubyn_code/memory/models.rb', line 45

def to_h
  {
    id: id,
    project_path: project_path,
    tier: tier,
    category: category,
    content: content,
    relevance_score: relevance_score,
    access_count: access_count,
    last_accessed_at: last_accessed_at,
    expires_at: expires_at,
    metadata: ,
    created_at: created_at
  }
end