class
Sepia::PathResolver
- Sepia::PathResolver
- Reference
- Object
Overview
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"
Defined in:
sepia/path_resolver.crConstructors
-
.new(storage_path : String)
Creates a new PathResolver
Instance Method Summary
-
#list_all_objects : Array(ObjectInfo)
List all Sepia objects in the storage directory
-
#resolve_and_load(full_path : String, klass : Class) : Object | Nil
Resolve a path and load the actual Sepia object
-
#resolve_path(full_path : String) : ObjectInfo | Nil
Resolve a file system path to Sepia object information
-
#storage_path : String
Base storage path for resolving objects
-
#storage_path=(storage_path : String)
Base storage path for resolving objects
-
#valid_sepia_path?(path : String) : Bool
Check if a path is a valid Sepia object path
Constructor Detail
Creates a new PathResolver
resolver = PathResolver.new("/data/sepia")
resolver = PathResolver.new(Sepia::Storage.instance.path)
Instance Method Detail
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
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
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"
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