class

Sepia::PathResolver

Inherits Reference < Object

Utility class for resolving file system paths to Sepia objects

This helper provides methods to convert file system paths back to Sepia objects, which is particularly useful for file system watchers and other tools that need to map file paths back to object instances.

Example

# Given a file path like "/data/MyDocument/uuid-123"
resolver = Sepia::PathResolver.new("/data")

info = resolver.resolve_path("/data/MyDocument/uuid-123")
info.class_name # => "MyDocument"
info.object_id  # => "uuid-123"
info.full_path  # => "/data/MyDocument/uuid-123"

Constructors

new(storage_path : String)

Creates a new PathResolver

resolver = PathResolver.new("/data/sepia")
resolver = PathResolver.new(Sepia::Storage.instance.path)
Source

Instance methods

list_all_objects

List all Sepia objects in the storage directory

Returns an array of ObjectInfo for all found objects

resolver = PathResolver.new("/data")
objects = resolver.list_all_objects
objects.each do |info|
  puts "#{info.class_name}: #{info.object_id}"
end
Source
resolve_and_load(full_path : String, klass : Class) : Object | Nil

Resolve a path and load the actual Sepia object

This is a convenience method that combines resolve_path and object loading

obj = resolver.resolve_and_load("/data/MyDocument/uuid-123", TestDocument)
if obj
  puts "Loaded: #{obj.class.name} (#{obj.sepia_id})"
end
Source
resolve_path(full_path : String) : ObjectInfo | Nil

Resolve a file system path to Sepia object information

info = resolver.resolve_path("/data/MyDocument/uuid-123")
info.class_name # => "MyDocument"
info.object_id  # => "uuid-123"
Source
storage_path

Base storage path for resolving objects

Source
storage_path=(storage_path : String)

Base storage path for resolving objects

Source
valid_sepia_path?(path : String) : Bool

Check if a path is a valid Sepia object path

if resolver.valid_sepia_path?("/data/MyDocument/uuid-123")
  puts "This is a valid Sepia object path"
end
Source

Nested types