Module: Ask::Actions
- Defined in:
- lib/ask/actions.rb,
lib/ask/actions/result.rb,
lib/ask/actions/backend.rb,
lib/ask/actions/context.rb
Overview
Actions — a convention for user-facing operations callable from any channel.
Every action lives in app/actions/, responds to .call(context:, params:), and returns an Ask::Actions::Result. Dispatch them by name so any channel — web, Slack, voice — can invoke the same operation:
Ask::Actions.dispatch(action: "chats.create", context: context, params: {})
By convention, "chats.create" resolves to Chats::Create (app/actions/chats/create.rb). Register explicitly to override the convention or to list actions in Ask::Actions.available:
Ask::Actions.register "chats.create", Chats::Create
Defined Under Namespace
Classes: Backend, Context, Result
Class Method Summary collapse
- .available ⇒ Object
- .dispatch(action:, context:, params: {}) ⇒ Object
- .register(action, klass) ⇒ Object
- .reset! ⇒ Object
- .resolve(action) ⇒ Object
Class Method Details
.available ⇒ Object
35 36 37 |
# File 'lib/ask/actions.rb', line 35 def available Backend.available end |
.dispatch(action:, context:, params: {}) ⇒ Object
27 28 29 |
# File 'lib/ask/actions.rb', line 27 def dispatch(action:, context:, params: {}) Backend.dispatch(action: action, context: context, params: params) end |