From 51ee1b5367b9535696e588a56169f29c4dddd975 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Sat, 28 Jan 2023 20:10:02 +0200 Subject: [PATCH] updated tagged hook methods to use h as short var --- tools/hook/tagged.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/hook/tagged.go b/tools/hook/tagged.go index 35906947e..47beb73ec 100644 --- a/tools/hook/tagged.go +++ b/tools/hook/tagged.go @@ -33,13 +33,13 @@ type TaggedHook[T Tagger] struct { // CanTriggerOn checks if the current TaggedHook can be triggered with // the provided event data tags. -func (p *TaggedHook[T]) CanTriggerOn(tags []string) bool { - if len(p.tags) == 0 { +func (h *TaggedHook[T]) CanTriggerOn(tags []string) bool { + if len(h.tags) == 0 { return true // match all } for _, t := range tags { - if list.ExistInSlice(t, p.tags) { + if list.ExistInSlice(t, h.tags) { return true } } @@ -49,10 +49,10 @@ func (p *TaggedHook[T]) CanTriggerOn(tags []string) bool { // PreAdd registers a new handler to the hook by prepending it to the existing queue. // -// The fn handler will be called only if the event data tags satisfy p.CanTriggerOn. -func (p *TaggedHook[T]) PreAdd(fn Handler[T]) { - p.mainHook.PreAdd(func(e T) error { - if p.CanTriggerOn(e.Tags()) { +// The fn handler will be called only if the event data tags satisfy h.CanTriggerOn. +func (h *TaggedHook[T]) PreAdd(fn Handler[T]) { + h.mainHook.PreAdd(func(e T) error { + if h.CanTriggerOn(e.Tags()) { return fn(e) } @@ -62,10 +62,10 @@ func (p *TaggedHook[T]) PreAdd(fn Handler[T]) { // Add registers a new handler to the hook by appending it to the existing queue. // -// The fn handler will be called only if the event data tags satisfy p.CanTriggerOn. -func (p *TaggedHook[T]) Add(fn Handler[T]) { - p.mainHook.Add(func(e T) error { - if p.CanTriggerOn(e.Tags()) { +// The fn handler will be called only if the event data tags satisfy h.CanTriggerOn. +func (h *TaggedHook[T]) Add(fn Handler[T]) { + h.mainHook.Add(func(e T) error { + if h.CanTriggerOn(e.Tags()) { return fn(e) }