Documentation ¶
Index ¶
- type Adaptable
- type Collection
- func (collection *Collection) Adapter() Adaptable
- func (collection *Collection) Create(values helpers.H) (Modellable, error)
- func (collection *Collection) List() *List
- func (collection *Collection) Name() string
- func (collection *Collection) New(values helpers.H) Modellable
- func (collection *Collection) Query() Queryable
- type FindPredicate
- type FiniteStateMachine
- func (fsm *FiniteStateMachine) AddStateHandler(stateName string, enterHandler func(string), runHandler func(), ...)
- func (fsm *FiniteStateMachine) Equals(stateName string) bool
- func (fsm *FiniteStateMachine) GetActiveAgent() interface{}
- func (fsm *FiniteStateMachine) GetEndAt() int64
- func (fsm *FiniteStateMachine) GetName() string
- func (fsm *FiniteStateMachine) GoTo(stateName string, item Modellable)
- func (fsm *FiniteStateMachine) IsTurnExpired() bool
- func (fsm *FiniteStateMachine) Run(item Modellable)
- func (fsm *FiniteStateMachine) SetTurn(activeAgent Modellable, endAt time.Time)
- type HooksHandler
- func (handler *HooksHandler) ExecuteAfterInstantiateHook()
- func (handler *HooksHandler) ExecuteAfterMemoizeHook()
- func (handler *HooksHandler) ExecuteInitializeHook(values *helpers.Dictionary)
- func (handler *HooksHandler) ExecuteValidationHooks() error
- func (handler *HooksHandler) RegisterAfterInstantiateHook(afterInstantiateHook func())
- func (handler *HooksHandler) RegisterAfterMemoizeHook(afterMemoizeHook func())
- func (handler *HooksHandler) RegisterInitializeHook(initializeHook func(*helpers.Dictionary))
- func (handler *HooksHandler) RegisterValidationHook(validationHook func() error)
- type List
- func (list *List) Add(item Modellable)
- func (list *List) Count() int
- func (list *List) Find(predicate FindPredicate) Modellable
- func (list *List) FindAll(predicate FindPredicate) []Modellable
- func (list *List) FindByID(id string) Modellable
- func (list *List) First() Modellable
- func (list *List) Items() []Modellable
- type Manager
- type Modellable
- type NewHandler
- type Queryable
- type StateHandler
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
Adapter used to retrieve collection's adapter
func (*Collection) Create ¶
func (collection *Collection) Create(values helpers.H) (Modellable, error)
Create used to create item
func (*Collection) List ¶ added in v0.0.51
func (collection *Collection) List() *List
List used to retrieve in-memory list
func (*Collection) Name ¶ added in v0.0.46
func (collection *Collection) Name() string
Name used to retrieve collection's name
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 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 List ¶ added in v0.0.51
type List struct {
// contains filtered or unexported fields
}
List is an in-memory storage of items
func (*List) Find ¶ added in v0.0.51
func (list *List) Find(predicate FindPredicate) Modellable
Find used to find item in collection, return nil if not found
func (*List) FindAll ¶ added in v0.0.51
func (list *List) FindAll(predicate FindPredicate) []Modellable
FindAll used to find items in collection
func (*List) FindByID ¶ added in v0.0.51
func (list *List) FindByID(id string) Modellable
FindByID used to find item in collection by id, return nil if not found
func (*List) First ¶ added in v0.0.51
func (list *List) First() Modellable
First used to return first item in collection
func (*List) Items ¶ added in v0.0.51
func (list *List) Items() []Modellable
Items used to return all items in collections
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) RegisterAdapter ¶ added in v0.0.39
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
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) FirstOrCreate(helpers.H) (Modellable, error) Find(string) (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