mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? - Implement chasm engine Update/Read Component method ## Why? - CHASM work stream ## How did you test it? - [x] built - [ ] run locally and tested manually - [ ] covered by existing tests - [x] added new unit test(s) - [ ] added new functional test(s)
30 lines
661 B
Go
30 lines
661 B
Go
package chasm
|
|
|
|
import "strings"
|
|
|
|
var _ NodePathEncoder = (*defaultPathEncoder)(nil)
|
|
|
|
var DefaultPathEncoder NodePathEncoder = &defaultPathEncoder{}
|
|
|
|
type defaultPathEncoder struct{}
|
|
|
|
// TODO: Have a real implementation for DefaultPathEncoder
|
|
// that handles special characters in the path and support
|
|
// getting all immedidate children of a collection node.
|
|
|
|
func (e *defaultPathEncoder) Encode(
|
|
_ *Node,
|
|
path []string,
|
|
) (string, error) {
|
|
return strings.Join(path, "/"), nil
|
|
}
|
|
|
|
func (e *defaultPathEncoder) Decode(
|
|
encodedPath string,
|
|
) ([]string, error) {
|
|
if encodedPath == "" {
|
|
return []string{}, nil
|
|
}
|
|
return strings.Split(encodedPath, "/"), nil
|
|
}
|