MCPcopy
hub / github.com/apache/casbin / LoadPolicyArray

Function LoadPolicyArray

persist/adapter.go:44–61  ·  view source on GitHub ↗

LoadPolicyArray loads a policy rule to model.

(rule []string, m model.Model)

Source from the content-addressed store, hash-verified

42
43// LoadPolicyArray loads a policy rule to model.
44func LoadPolicyArray(rule []string, m model.Model) error {
45 key := rule[0]
46 sec := key[:1]
47 ok, err := m.HasPolicyEx(sec, key, rule[1:])
48 if err != nil {
49 return err
50 }
51 if ok {
52 return nil // skip duplicated policy
53 }
54
55 err = m.AddPolicy(sec, key, rule[1:])
56 if err != nil {
57 return err
58 }
59
60 return nil
61}
62
63// Adapter is the interface for Casbin adapters.
64type Adapter interface {

Callers 2

LoadPolicyLineFunction · 0.85

Calls 2

HasPolicyExMethod · 0.80
AddPolicyMethod · 0.65

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…