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

Class Method Details

.availableObject



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

.register(action, klass) ⇒ Object



23
24
25
# File 'lib/ask/actions.rb', line 23

def register(action, klass)
  Backend.register(action, klass)
end

.reset!Object



39
40
41
# File 'lib/ask/actions.rb', line 39

def reset!
  Backend.reset!
end

.resolve(action) ⇒ Object



31
32
33
# File 'lib/ask/actions.rb', line 31

def resolve(action)
  Backend.resolve(action)
end