MCPcopy Index your code
hub / github.com/apache/casbin / LoadModel

Method LoadModel

enforcer.go:206–219  ·  view source on GitHub ↗

LoadModel reloads the model from the model CONF file. Because the policy is attached to a model, so the policy is invalidated and needs to be reloaded by calling LoadPolicy().

()

Source from the content-addressed store, hash-verified

204// LoadModel reloads the model from the model CONF file.
205// Because the policy is attached to a model, so the policy is invalidated and needs to be reloaded by calling LoadPolicy().
206func (e *Enforcer) LoadModel() error {
207 var err error
208 e.model, err = model.NewModelFromFile(e.modelPath)
209 if err != nil {
210 return err
211 }
212
213 e.model.PrintModel()
214 e.fm = model.LoadFunctionMap()
215
216 e.initialize()
217
218 return nil
219}
220
221// GetModel gets the current model.
222func (e *Enforcer) GetModel() model.Model {

Callers 4

TestEnforceConcurrencyFunction · 0.95
TestNoErrorFunction · 0.95
TestModelNoErrorFunction · 0.95

Calls 4

initializeMethod · 0.95
NewModelFromFileFunction · 0.92
LoadFunctionMapFunction · 0.92
PrintModelMethod · 0.80

Tested by 4

TestEnforceConcurrencyFunction · 0.76
TestNoErrorFunction · 0.76
TestModelNoErrorFunction · 0.76