Class: OllamaChat::Database::Models::Favourite
- Inherits:
-
Object
- Object
- OllamaChat::Database::Models::Favourite
- Defined in:
- lib/ollama_chat/database/models/favourite.rb
Overview
Represents a user-defined favourite entry within a specific context (e.g., a model).
This model provides a mechanism to persist preferred items, such as favourite models, by storing their name and an associated JSON-serialized metadata hash. It utilizes Sequel plugins for managing timestamps and handling JSON serialization for the ‘metadata` attribute.
Instance Method Summary collapse
-
#context(value) ⇒ String
The context in which this favourite exists (e.g., ‘model’).
-
#created_at(value) ⇒ Time?
The timestamp when the favourite was created.
-
#id(value) ⇒ Integer
The primary key for the favourite entry.
-
#metadata(value) ⇒ Hash?
A JSON-serialized hash containing additional metadata.
-
#name(value) ⇒ String
The name of the favourite item.
-
#updated_at(value) ⇒ Time?
The timestamp of the last update to the favourite.
-
#validate ⇒ Object
Validates the favourite entry.
Instance Method Details
#context=(value) ⇒ String
Returns The context in which this favourite exists (e.g., ‘model’).
|
|
# File 'lib/ollama_chat/database/models/favourite.rb', line 24
|
#created_at=(value) ⇒ Time?
Returns The timestamp when the favourite was created.
|
|
# File 'lib/ollama_chat/database/models/favourite.rb', line 24
|
#id=(value) ⇒ Integer
Returns The primary key for the favourite entry.
|
|
# File 'lib/ollama_chat/database/models/favourite.rb', line 24
|
#metadata=(value) ⇒ Hash?
Returns A JSON-serialized hash containing additional metadata.
|
|
# File 'lib/ollama_chat/database/models/favourite.rb', line 24
|
#name=(value) ⇒ String
Returns The name of the favourite item.
|
|
# File 'lib/ollama_chat/database/models/favourite.rb', line 24
|
#updated_at=(value) ⇒ Time?
Returns The timestamp of the last update to the favourite.
|
|
# File 'lib/ollama_chat/database/models/favourite.rb', line 24
|
#validate ⇒ Object
Validates the favourite entry.
Ensures that both the ‘context` and `name` are present.
17 18 19 20 21 22 |
# File 'lib/ollama_chat/database/models/favourite.rb', line 17 def validate super validates_presence :context validates_presence :name validates_unique %i[ context name ] end |