MCPcopy
hub / github.com/go-gorm/gorm / compile

Method compile

callbacks.go:194–215  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

192}
193
194func (p *processor) compile() (err error) {
195 var callbacks []*callback
196 removedMap := map[string]bool{}
197 for _, callback := range p.callbacks {
198 if callback.match == nil || callback.match(p.db) {
199 callbacks = append(callbacks, callback)
200 }
201 if callback.remove {
202 removedMap[callback.name] = true
203 }
204 }
205
206 if len(removedMap) > 0 {
207 callbacks = removeCallbacks(callbacks, removedMap)
208 }
209 p.callbacks = callbacks
210
211 if p.fns, err = sortCallbacks(p.callbacks); err != nil {
212 p.db.Logger.Error(context.Background(), "Got error when compile callbacks, got %v", err)
213 }
214 return
215}
216
217func (c *callback) Before(name string) *callback {
218 c.before = name

Callers 3

RegisterMethod · 0.80
RemoveMethod · 0.80
ReplaceMethod · 0.80

Calls 3

removeCallbacksFunction · 0.85
sortCallbacksFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected