Sphynx.Riddle behaviour (Sphynx v0.1.0) View Source
Main module for making riddles
Link to this section Summary
Types
A custom module of user which implement Sphynx.Riddle
Callbacks
Returns answer for riddle. Will be called when user gonna try to check his answer.
Checking answer for current riddle
Returns context for riddle. This function will be called when you try to create riddle.
Returns init args
Pre-action of making a riddle. As example, it can be email or SMS sending.
Handles result of checking answer to riddle
Link to this section Types
Specs
user_module() :: %{options: Keyword.t(), register: List.t(), context: Any.t()}
A custom module of user which implement Sphynx.Riddle
Link to this section Callbacks
Specs
answer(user_module()) :: Any.t()
Returns answer for riddle. Will be called when user gonna try to check his answer.
Specs
check(user_module(), Any.t(), Any.t()) :: Boolean.t()
Checking answer for current riddle
Args:
- riddle - user module,
Sphynx.Riddle
implementation - actual_answer - answer, returned by user module or actual in struct
- answer - the received answer that we have to check
Specs
context(user_module()) :: Any.t()
Returns context for riddle. This function will be called when you try to create riddle.
Function passes context data and return context data.
Specs
Returns init args
Specs
make(user_module()) :: user_module()
Pre-action of making a riddle. As example, it can be email or SMS sending.
Args
- riddle - user module,
Sphynx.Riddle
implementation
Returns self
Specs
verdict(user_module(), Any.t()) :: Any.t()
Handles result of checking answer to riddle
Args:
- riddle - user module,
Sphynx.Riddle
implementation - result - result of calling
check/3
function
Returns:
- if result is {:proceed, user_module()} - gonna ge started new riddle
- if result is {:break, _} - clash gonna be stopped
- if result has another data - this another data will be returned
Link to this section Functions
Specs
put_context(user_module(), Any.t()) :: user_module()
Function for putting custom context data
Specs
put_options(user_module(), Map.t()) :: user_module()
Function for putting user options