Class: Aws::Lex::Conversation::Handler::SlotResolution

Inherits:
Base
  • Object
show all
Defined in:
lib/aws/lex/conversation/handler/slot_resolution.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #successor

Instance Method Summary collapse

Methods inherited from Base

#handle, #initialize

Constructor Details

This class inherits a constructor from Aws::Lex::Conversation::Handler::Base

Instance Method Details

#response(conversation) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/aws/lex/conversation/handler/slot_resolution.rb', line 14

def response(conversation)
  # resolve all slots to their top resolution
  conversation.slots.values.each(&:resolve!)

  unless successor
    msg = 'Handler `SlotResolution` must not be the final handler in the chain'
    raise Exception::MissingHandler, msg
  end

  # call the next handler in the chain
  successor.handle(conversation)
end

#will_respond?(conversation) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
# File 'lib/aws/lex/conversation/handler/slot_resolution.rb', line 8

def will_respond?(conversation)
  # respond by default unless told otherwise
  callable = options.fetch(:respond_on) { ->(_c) { true } }
  callable.call(conversation)
end