Class: OllamaChat::Database::Models::Favourite

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

Instance Method Details

#context=(value) ⇒ String

Returns The context in which this favourite exists (e.g., 'model').

Returns:

  • (String)

    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.

Returns:

  • (Time, nil)

    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.

Returns:

  • (Integer)

    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.

Returns:

  • (Hash, nil)

    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.

Returns:

  • (String)

    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.

Returns:

  • (Time, nil)

    The timestamp of the last update to the favourite.



# File 'lib/ollama_chat/database/models/favourite.rb', line 24

#validateObject

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