models

package
v0.0.46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adaptable added in v0.0.46

type Adaptable interface {
	NewQuery(*Collection) Queryable
	RegisterCollection(*Collection)
	Collections() []*Collection
}

type Collection

type Collection struct {
	// contains filtered or unexported fields
}

Collection used to contain models

func (*Collection) Adapter added in v0.0.46

func (collection *Collection) Adapter() Adaptable

func (*Collection) Create

func (collection *Collection) Create(values helpers.H) (Modellable, error)

Create used to create item

func (*Collection) Memo added in v0.0.46

func (collection *Collection) Memo() *CollectionMemo

func (*Collection) Name added in v0.0.46

func (collection *Collection) Name() string

func (*Collection) New added in v0.0.39

func (collection *Collection) New(values helpers.H) Modellable

New used to initialize item

func (*Collection) Query added in v0.0.39

func (collection *Collection) Query() Queryable

Query returns query wrapper for retrieving records in adapter

type CollectionMemo added in v0.0.42

type CollectionMemo struct {
	// contains filtered or unexported fields
}

func (*CollectionMemo) Add added in v0.0.46

func (memo *CollectionMemo) Add(item Modellable)

Add used to memoize item

func (*CollectionMemo) Count added in v0.0.42

func (memo *CollectionMemo) Count() int

Count used to count items

func (*CollectionMemo) Find added in v0.0.42

func (memo *CollectionMemo) Find(predicate FindPredicate) Modellable

Find used to find item in collection, return nil if not found

func (*CollectionMemo) FindAll added in v0.0.42

func (memo *CollectionMemo) FindAll(predicate FindPredicate) []Modellable

FindAll used to find items in collection

func (*CollectionMemo) FindByID added in v0.0.42

func (memo *CollectionMemo) FindByID(id string) Modellable

FindByID used to find item in collection by id, return nil if not found

func (*CollectionMemo) First added in v0.0.42

func (memo *CollectionMemo) First() Modellable

First used to return first item in collection

func (*CollectionMemo) GetItems added in v0.0.42

func (memo *CollectionMemo) GetItems() []Modellable

GetItems used to return all items in collections

type FindPredicate added in v0.0.21

type FindPredicate func(Modellable) bool

FindPredicate is alias for func(Modellable) bool

type FiniteStateMachine

type FiniteStateMachine struct {
	// contains filtered or unexported fields
}

FiniteStateMachine used to implement fsm

func MakeFiniteStateMachine

func MakeFiniteStateMachine(defaultStateName string) *FiniteStateMachine

MakeFiniteStateMachine used to instantiate fsm

func (*FiniteStateMachine) AddStateHandler

func (fsm *FiniteStateMachine) AddStateHandler(
	stateName string,
	enterHandler func(string),
	runHandler func(),
	exitHandler func(),
)

AddStateHandler used to add handler for fsm's state

func (*FiniteStateMachine) Equals

func (fsm *FiniteStateMachine) Equals(stateName string) bool

Equals used to compare fsm's state

func (*FiniteStateMachine) GetActiveAgent

func (fsm *FiniteStateMachine) GetActiveAgent() interface{}

GetActiveAgent used to get fsm's active agent at current turn

func (*FiniteStateMachine) GetEndAt

func (fsm *FiniteStateMachine) GetEndAt() int64

GetEndAt used to get turn's end time

func (*FiniteStateMachine) GetName

func (fsm *FiniteStateMachine) GetName() string

GetName used to get fsm's state name

func (*FiniteStateMachine) GoTo

func (fsm *FiniteStateMachine) GoTo(stateName string, item Modellable)

GoTo used for fsm's state transition

func (*FiniteStateMachine) IsTurnExpired

func (fsm *FiniteStateMachine) IsTurnExpired() bool

IsTurnExpired used to check if turn is expired

func (*FiniteStateMachine) Run

func (fsm *FiniteStateMachine) Run(item Modellable)

Run used to run fsm's state

func (*FiniteStateMachine) SetTurn

func (fsm *FiniteStateMachine) SetTurn(activeAgent Modellable, endAt time.Time)

SetTurn used to set new turn

type HooksHandler added in v0.0.39

type HooksHandler struct {
	// contains filtered or unexported fields
}

HooksHandler used to mange callbacks for models

func (*HooksHandler) ExecuteAfterInstantiateHook added in v0.0.46

func (handler *HooksHandler) ExecuteAfterInstantiateHook()

ExecuteAfterInstantiateHook used to execute after instantiate hook

func (*HooksHandler) ExecuteAfterMemoizeHook added in v0.0.46

func (handler *HooksHandler) ExecuteAfterMemoizeHook()

ExecuteAfterMemoizeHook used to execute after memoize hook

func (*HooksHandler) ExecuteInitializeHook added in v0.0.46

func (handler *HooksHandler) ExecuteInitializeHook(values *helpers.Dictionary)

ExecuteInitializeHook used to execute after initialize hook

func (*HooksHandler) ExecuteValidationHooks added in v0.0.46

func (handler *HooksHandler) ExecuteValidationHooks() error

ExecuteValidationHooks used to execute validation hooks

func (*HooksHandler) RegisterAfterInstantiateHook added in v0.0.41

func (handler *HooksHandler) RegisterAfterInstantiateHook(afterInstantiateHook func())

RegisterAfterInstantiateHook used to add after instantiate hook

func (*HooksHandler) RegisterAfterMemoizeHook added in v0.0.42

func (handler *HooksHandler) RegisterAfterMemoizeHook(afterMemoizeHook func())

RegisterAfterMemoizeHook used to add after memoize hook

func (*HooksHandler) RegisterInitializeHook added in v0.0.40

func (handler *HooksHandler) RegisterInitializeHook(initializeHook func(*helpers.Dictionary))

RegisterInitializeHook used to add initialize hook

func (*HooksHandler) RegisterValidationHook added in v0.0.39

func (handler *HooksHandler) RegisterValidationHook(validationHook func() error)

RegisterValidationHook used to add a validation hook

type Manager added in v0.0.22

type Manager struct {
	// contains filtered or unexported fields
}

Manager is a singleton used to manager model's behavior

func (*Manager) Adapter added in v0.0.46

func (manager *Manager) Adapter(clientName string) Adaptable

Adapter used to retrieve registered adapter

func (*Manager) RegisterAdapter added in v0.0.39

func (manager *Manager) RegisterAdapter(clientName string, adapter Adaptable)

RegisterAdapter used to register adapter

func (*Manager) RegisterCollection added in v0.0.22

func (manager *Manager) RegisterCollection(clientName string, collectionName string, newHandler NewHandler) *Collection

RegisterCollection used to create a collection for models manager

func (*Manager) Setup added in v0.0.22

func (manager *Manager) Setup()

Setup used to setup manager

type Modellable added in v0.0.21

type Modellable interface {
	InitializeBase(*Collection, *HooksHandler, Modellable)
	GetID() string
	Save() error
	Memoize()
	GetHooksHandler() *HooksHandler
}

Modellable is the interface for all models implementing model's functionalities

type NewHandler added in v0.0.39

type NewHandler func(*Collection, *HooksHandler) Modellable

NewHandler is alias for func(args ...interface{}) Modellable

type Queryable added in v0.0.39

type Queryable interface {
	Where(filter helpers.H) Queryable
	Count() (int64, error)
	Each(func(Modellable, error) bool) error
	First() (Modellable, error)
}

Queryable is the interface for all query adapter implementing query's functionalities

type StateHandler

type StateHandler struct {
	// contains filtered or unexported fields
}

StateHandler used to

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL