// Copyright (c) 2024 Zeni Kim <zenik@smarteching.com>
// Use of this source code is governed by MIT-style
// license that can be found in the LICENSE file.

package core

type Hooks struct {
	hooks []Hook
}

var m *Hooks

func NewHooks() *Hooks {
	m = &Hooks{}
	return m
}

func ResolveHooks() *Hooks {
	return m
}

func (m *Hooks) Attach(mw Hook) *Hooks {
	m.hooks = append(m.hooks, mw)

	return m
}

func (m *Hooks) GetHooks() []Hook {
	return m.hooks
}

func (m *Hooks) getByIndex(i int) Hook {
	for k := range m.hooks {
		if k == i {
			return m.hooks[i]
		}
	}
	return nil
}