Class: ClaudeMemory::Domain::Entity
- Inherits:
-
Object
- Object
- ClaudeMemory::Domain::Entity
- 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
-
#canonical_name ⇒ Object
readonly
Returns the value of attribute canonical_name.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#database? ⇒ Boolean
True when type is “database”.
-
#framework? ⇒ Boolean
True when type is “framework”.
-
#initialize(attributes) ⇒ Entity
constructor
A new instance of Entity.
-
#person? ⇒ Boolean
True when type is “person”.
-
#to_h ⇒ Hash
All attributes as a plain hash.
Constructor Details
#initialize(attributes) ⇒ Entity
Returns a new instance of Entity.
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_name ⇒ Object (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_at ⇒ Object (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 |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/claude_memory/domain/entity.rb', line 8 def id @id end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
8 9 10 |
# File 'lib/claude_memory/domain/entity.rb', line 8 def slug @slug end |
#type ⇒ Object (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”.
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”.
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”.
39 40 41 |
# File 'lib/claude_memory/domain/entity.rb', line 39 def person? type == "person" end |
#to_h ⇒ Hash
Returns 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 |