MCPcopy Create free account
hub / github.com/Permify/permify / WalkRewrite

Method WalkRewrite

internal/schema/walker.go:80–103  ·  view source on GitHub ↗

WalkRewrite is a method that walks through the rewrite part of the schema

(
	entityType string,
	rewrite *base.Rewrite,
)

Source from the content-addressed store, hash-verified

78
79// WalkRewrite is a method that walks through the rewrite part of the schema
80func (w *Walker) WalkRewrite(
81 entityType string,
82 rewrite *base.Rewrite,
83) error {
84 // Loop through each child in the rewrite
85 for _, child := range rewrite.GetChildren() {
86 // Switch on the type of the child
87 switch child.GetType().(type) {
88 case *base.Child_Rewrite:
89 if err := w.WalkRewrite(entityType, child.GetRewrite()); err != nil {
90 return err
91 }
92 case *base.Child_Leaf:
93 if err := w.WalkLeaf(entityType, child.GetLeaf()); err != nil {
94 return err
95 }
96 default:
97 // For any other child type, return an error indicating an undefined child type
98 return errors.New(base.ErrorCode_ERROR_CODE_UNDEFINED_CHILD_KIND.String())
99 }
100 }
101 // If no errors occurred during the loop, return nil
102 return nil
103}
104
105// WalkComputedUserSet walk the relation within the ComputedUserSet for the given entityType.
106func (w *Walker) WalkComputedUserSet(

Callers 1

WalkMethod · 0.95

Calls 6

WalkLeafMethod · 0.95
GetRewriteMethod · 0.80
GetTypeMethod · 0.65
StringMethod · 0.65
GetChildrenMethod · 0.45
GetLeafMethod · 0.45

Tested by

no test coverage detected