Class: Aws::Lex::Conversation::Handler::Base
- Inherits:
-
Object
- Object
- Aws::Lex::Conversation::Handler::Base
- Defined in:
- lib/aws/lex/conversation/handler/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#successor ⇒ Object
Returns the value of attribute successor.
Instance Method Summary collapse
- #handle(conversation) ⇒ Object
-
#initialize(opts = {}) ⇒ Base
constructor
A new instance of Base.
- #response(_conversation) ⇒ Object
- #will_respond?(conversation) ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ Base
Returns a new instance of Base.
10 11 12 13 |
# File 'lib/aws/lex/conversation/handler/base.rb', line 10 def initialize(opts = {}) self.successor = opts[:successor] self. = opts[:options] || {} end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/aws/lex/conversation/handler/base.rb', line 8 def @options end |
#successor ⇒ Object
Returns the value of attribute successor.
8 9 10 |
# File 'lib/aws/lex/conversation/handler/base.rb', line 8 def successor @successor end |
Instance Method Details
#handle(conversation) ⇒ Object
24 25 26 27 28 29 |
# 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) ⇒ Object
20 21 22 |
# File 'lib/aws/lex/conversation/handler/base.rb', line 20 def response(_conversation) raise NotImplementedError, 'define #response in a subclass' end |
#will_respond?(conversation) ⇒ Boolean
15 16 17 18 |
# File 'lib/aws/lex/conversation/handler/base.rb', line 15 def will_respond?(conversation) callable = .fetch(:respond_on) { ->(_c) { false } } callable.call(conversation) end |