31 lines
492 B
Go
31 lines
492 B
Go
package engine
|
|
|
|
type engineOptions struct {
|
|
debug bool
|
|
relations []string
|
|
}
|
|
|
|
type EngineOption interface {
|
|
apply(*engineOptions)
|
|
}
|
|
|
|
type fnOption struct {
|
|
f func(*engineOptions)
|
|
}
|
|
|
|
func (this fnOption) apply(do *engineOptions) {
|
|
this.f(do)
|
|
}
|
|
|
|
func Debug() EngineOption {
|
|
return &fnOption{f: func(o *engineOptions) {
|
|
o.debug = true
|
|
}}
|
|
}
|
|
|
|
func Relation(opts ...string) EngineOption {
|
|
return &fnOption{f: func(o *engineOptions) {
|
|
o.relations = append(o.relations, opts...)
|
|
}}
|
|
}
|