class Sepia::Storage

Overview

The Storage class is responsible for handling the persistence of Sepia::Serializable and Sepia::Container objects to the file system. It manages saving and loading these objects based on their sepia_id and class name, and provides a configurable storage path.

Defined in:

sepia/storage.cr

Constant Summary

INSTANCE = new

Instance Method Summary

Instance Method Detail

def delete(object : Serializable) #

[View source]
def delete(object : Container) #

[View source]
def load(object_class : T.class, id : String, path : String | Nil = nil) : T forall T #

Load an object from the canonical path in sepia format. T must be a class that includes Sepia::Serializable or Sepia::Container.


[View source]
def path : String #

By default, the storage path is a temporary directory.


[View source]
def path=(path : String) #

But user can override it. Sets the storage path. This is where all serialized objects will be stored.


[View source]
def save(object : Serializable, path : String | Nil = nil) #

Saves a Serializable object to its canonical path. The object's to_sepia method is used to get the content to be saved.


[View source]
def save(object : Container, path : String | Nil = nil) #

Saves a Container object to its canonical path as a directory. The container's save_references method is called to save its contents.


[View source]