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

Function countModelRules

util_log.go:50–63  ·  view source on GitHub ↗

countModelRules counts the total number of rules in a model's p and g sections.

(m model.Model)

Source from the content-addressed store, hash-verified

48
49// countModelRules counts the total number of rules in a model's p and g sections.
50func countModelRules(m model.Model) int {
51 ruleCount := 0
52 if pSection, ok := m["p"]; ok {
53 for _, ast := range pSection {
54 ruleCount += len(ast.Policy)
55 }
56 }
57 if gSection, ok := m["g"]; ok {
58 for _, ast := range gSection {
59 ruleCount += len(ast.Policy)
60 }
61 }
62 return ruleCount
63}
64
65// onLogBeforeEventInLoadPolicy initializes logging for LoadPolicy operation.
66func (e *Enforcer) onLogBeforeEventInLoadPolicy() *log.LogEntry {

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…