Class: ClaudeMemory::Domain::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_memory/domain/entity.rb

Overview

Domain model representing an entity (database, framework, person, etc.). Instances are immutable (frozen).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Entity

Returns a new instance of Entity.

Parameters:

  • attributes (Hash)

    entity attributes

Options Hash (attributes):

  • :id (Integer)

    database primary key

  • :type (String)

    entity category (required, e.g. “database”, “framework”, “person”)

  • :canonical_name (String)

    display name (required)

  • :slug (String)

    URL-safe identifier (required)

  • :created_at (String)

    ISO 8601 creation timestamp

Raises:

  • (ArgumentError)

    if type, canonical_name, or slug is blank



17
18
19
20
21
22
23
24
25
26
# File 'lib/claude_memory/domain/entity.rb', line 17

def initialize(attributes)
  @id = attributes[:id]
  @type = attributes[:type]
  @canonical_name = attributes[:canonical_name]
  @slug = attributes[:slug]
  @created_at = attributes[:created_at]

  validate!
  freeze
end

Instance Attribute Details

#canonical_nameObject (readonly)

Returns the value of attribute canonical_name.



8
9
10
# File 'lib/claude_memory/domain/entity.rb', line 8

def canonical_name
  @canonical_name
end

#created_atObject (readonly)

Returns the value of attribute created_at.



8
9
10
# File 'lib/claude_memory/domain/entity.rb', line 8

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/claude_memory/domain/entity.rb', line 8

def id
  @id
end

#slugObject (readonly)

Returns the value of attribute slug.



8
9
10
# File 'lib/claude_memory/domain/entity.rb', line 8

def slug
  @slug
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/claude_memory/domain/entity.rb', line 8

def type
  @type
end

Instance Method Details

#database?Boolean

Returns true when type is “database”.

Returns:

  • (Boolean)

    true when type is “database”



29
30
31
# File 'lib/claude_memory/domain/entity.rb', line 29

def database?
  type == "database"
end

#framework?Boolean

Returns true when type is “framework”.

Returns:

  • (Boolean)

    true when type is “framework”



34
35
36
# File 'lib/claude_memory/domain/entity.rb', line 34

def framework?
  type == "framework"
end

#person?Boolean

Returns true when type is “person”.

Returns:

  • (Boolean)

    true when type is “person”



39
40
41
# File 'lib/claude_memory/domain/entity.rb', line 39

def person?
  type == "person"
end

#to_hHash

Returns all attributes as a plain hash.

Returns:

  • (Hash)

    all attributes as a plain hash



44
45
46
47
48
49
50
51
52
# File 'lib/claude_memory/domain/entity.rb', line 44

def to_h
  {
    id: id,
    type: type,
    canonical_name: canonical_name,
    slug: slug,
    created_at: created_at
  }
end