class Aws::Lex::Conversation::Handler::Base

Attributes

options[RW]
successor[RW]

Public Class Methods

new(opts = {}) click to toggle source
# File lib/aws/lex/conversation/handler/base.rb, line 10
def initialize(opts = {})
  self.successor = opts[:successor]
  self.options = opts[:options] || {}
end

Public Instance Methods

handle(conversation) click to toggle source
# File lib/aws/lex/conversation/handler/base.rb, line 24
def handle(conversation)
  return response(conversation) if will_respond?(conversation)
  return unless successor # end of chain - return nil

  successor.handle(conversation)
end
response(_conversation) click to toggle source
# File lib/aws/lex/conversation/handler/base.rb, line 20
def response(_conversation)
  raise NotImplementedError, 'define #response in a subclass'
end
will_respond?(conversation) click to toggle source
# File lib/aws/lex/conversation/handler/base.rb, line 15
def will_respond?(conversation)
  callable = options.fetch(:respond_on) { ->(_c) { false } }
  callable.call(conversation)
end