Rename Enabled* methods to IsEnabled*
This commit is contained in:
parent
4e119270f2
commit
5356b604eb
2
main.go
2
main.go
@ -808,7 +808,7 @@ func (s *DB) EnableAfterScanCallback(typs ...interface{}) *DB {
|
||||
|
||||
// Return if after scan callbacks has be enable. If typs is empty, return default, other else, return for informed
|
||||
// typs.
|
||||
func (s *DB) EnabledAfterScanCallback(typs ...interface{}) (ok bool) {
|
||||
func (s *DB) IsEnabledAfterScanCallback(typs ...interface{}) (ok bool) {
|
||||
key := "gorm:disable_after_scan"
|
||||
|
||||
if v, ok := s.values[key]; ok {
|
||||
|
@ -106,7 +106,7 @@ func (registrator *StructFieldMethodCallbacksRegistrator) DisableFieldType(typs
|
||||
}
|
||||
|
||||
// Return if all callbacks for field type is enabled
|
||||
func (registrator *StructFieldMethodCallbacksRegistrator) EnabledFieldType(typ interface{}) bool {
|
||||
func (registrator *StructFieldMethodCallbacksRegistrator) IsEnabledFieldType(typ interface{}) bool {
|
||||
if enabled, ok := registrator.FieldTypes.Get(typ); ok {
|
||||
return enabled
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ func init() {
|
||||
|
||||
func ExampleStructFieldMethodCallbacksRegistrator_DisableFieldType() {
|
||||
fmt.Println(`
|
||||
if registrator.EnabledFieldType(&Media{}) {
|
||||
if registrator.IsEnabledFieldType(&Media{}) {
|
||||
registrator.DisableFieldType(&Media{})
|
||||
}
|
||||
`)
|
||||
@ -18,7 +18,7 @@ if registrator.EnabledFieldType(&Media{}) {
|
||||
|
||||
func ExampleStructFieldMethodCallbacksRegistrator_EnabledFieldType() {
|
||||
fmt.Println(`
|
||||
if !registrator.EnabledFieldType(&Media{}) {
|
||||
if !registrator.IsEnabledFieldType(&Media{}) {
|
||||
println("not enabled")
|
||||
}
|
||||
`)
|
||||
@ -26,7 +26,7 @@ if !registrator.EnabledFieldType(&Media{}) {
|
||||
|
||||
func ExampleStructFieldMethodCallbacksRegistrator_EnableFieldType() {
|
||||
fmt.Println(`
|
||||
if !registrator.EnabledFieldType(&Media{}) {
|
||||
if !registrator.IsEnabledFieldType(&Media{}) {
|
||||
registrator.EnableFieldType(&Media{})
|
||||
}
|
||||
`)
|
||||
|
4
scope.go
4
scope.go
@ -476,11 +476,11 @@ func (scope *Scope) quoteIfPossible(str string) string {
|
||||
// call after field method callbacks
|
||||
func (scope *Scope) afterScanCallback(scannerFields map[int]*Field, disableScanField map[int]bool) {
|
||||
if !scope.HasError() && scope.Value != nil {
|
||||
if scope.DB().EnabledAfterScanCallback(scope.Value) {
|
||||
if scope.DB().IsEnabledAfterScanCallback(scope.Value) {
|
||||
scopeValue := reflect.ValueOf(scope)
|
||||
for index, field := range scannerFields {
|
||||
// if not is nill and if calbacks enabled for field type
|
||||
if StructFieldMethodCallbacks.EnabledFieldType(field.Field.Type()) {
|
||||
if StructFieldMethodCallbacks.IsEnabledFieldType(field.Field.Type()) {
|
||||
// not disabled on scan
|
||||
if _, ok := disableScanField[index]; !ok {
|
||||
if !isNil(field.Field) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user