forked from sas1024/gorm-loggable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.go
More file actions
31 lines (25 loc) · 770 Bytes
/
options.go
File metadata and controls
31 lines (25 loc) · 770 Bytes
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
package loggable
import "reflect"
type Option func(options *options)
type options struct {
lazyUpdate bool
lazyUpdateFields []string
metaTypes map[string]reflect.Type
objectTypes map[string]reflect.Type
}
func LazyUpdate(fields ...string) Option {
return func(options *options) {
options.lazyUpdate = true
options.lazyUpdateFields = fields
}
}
func RegObjectType(objectType string, objectStruct interface{}) Option {
return func(options *options) {
options.objectTypes[objectType] = reflect.Indirect(reflect.ValueOf(objectStruct)).Type()
}
}
func RegMetaType(objectType string, metaType interface{}) Option {
return func(options *options) {
options.metaTypes[objectType] = reflect.Indirect(reflect.ValueOf(metaType)).Type()
}
}