Class: Ralyxa::Skill
- Inherits:
-
Object
- Object
- Ralyxa::Skill
- Defined in:
- lib/ralyxa/skill.rb
Class Method Summary collapse
- .handle(request, alexa_request_wrapper = Ralyxa::RequestEntities::Request) ⇒ Object
- .handlers ⇒ Object
- .intent(intent_name, handler_base_class = Ralyxa::Handler, &intent_block) ⇒ Object
Instance Method Summary collapse
- #handle ⇒ Object
-
#initialize(request) ⇒ Skill
constructor
A new instance of Skill.
Constructor Details
#initialize(request) ⇒ Skill
Returns a new instance of Skill.
9 10 11 |
# File 'lib/ralyxa/skill.rb', line 9 def initialize(request) @request = request end |
Class Method Details
.handle(request, alexa_request_wrapper = Ralyxa::RequestEntities::Request) ⇒ Object
25 26 27 |
# File 'lib/ralyxa/skill.rb', line 25 def handle(request, alexa_request_wrapper = Ralyxa::RequestEntities::Request) new(alexa_request_wrapper.new(request)).handle end |
.handlers ⇒ Object
29 30 31 |
# File 'lib/ralyxa/skill.rb', line 29 def handlers @handlers.dup end |
.intent(intent_name, handler_base_class = Ralyxa::Handler, &intent_block) ⇒ Object
19 20 21 22 23 |
# File 'lib/ralyxa/skill.rb', line 19 def intent(intent_name, handler_base_class = Ralyxa::Handler, &intent_block) intent_handler = Class.new(handler_base_class) intent_handler.send(:define_method, :handle, &intent_block) @handlers[intent_name] = intent_handler end |
Instance Method Details
#handle ⇒ Object
13 14 15 16 |
# File 'lib/ralyxa/skill.rb', line 13 def handle handler = self.class.handlers[@request.intent_name] handler ? handler.new(@request).handle : warn(handler_not_found) end |