forked from gobuffalo/pop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
callbacks.go
89 lines (73 loc) · 1.65 KB
/
callbacks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package pop
type beforeSaveable interface {
BeforeSave(*Connection) error
}
func (m *Model) beforeSave(c *Connection) error {
if x, ok := m.Value.(beforeSaveable); ok {
return x.BeforeSave(c)
}
return nil
}
type beforeCreateable interface {
BeforeCreate(*Connection) error
}
func (m *Model) beforeCreate(c *Connection) error {
if x, ok := m.Value.(beforeCreateable); ok {
return x.BeforeCreate(c)
}
return nil
}
type beforeUpdateable interface {
BeforeUpdate(*Connection) error
}
func (m *Model) beforeUpdate(c *Connection) error {
if x, ok := m.Value.(beforeUpdateable); ok {
return x.BeforeUpdate(c)
}
return nil
}
type beforeDestroyable interface {
BeforeDestroy(*Connection) error
}
func (m *Model) beforeDestroy(c *Connection) error {
if x, ok := m.Value.(beforeDestroyable); ok {
return x.BeforeDestroy(c)
}
return nil
}
type afterDestroyable interface {
AfterDestroy(*Connection) error
}
func (m *Model) afterDestroy(c *Connection) error {
if x, ok := m.Value.(afterDestroyable); ok {
return x.AfterDestroy(c)
}
return nil
}
type afterUpdateable interface {
AfterUpdate(*Connection) error
}
func (m *Model) afterUpdate(c *Connection) error {
if x, ok := m.Value.(afterUpdateable); ok {
return x.AfterUpdate(c)
}
return nil
}
type afterCreateable interface {
AfterCreate(*Connection) error
}
func (m *Model) afterCreate(c *Connection) error {
if x, ok := m.Value.(afterCreateable); ok {
return x.AfterCreate(c)
}
return nil
}
type afterSaveable interface {
AfterSave(*Connection) error
}
func (m *Model) afterSave(c *Connection) error {
if x, ok := m.Value.(afterSaveable); ok {
return x.AfterSave(c)
}
return nil
}