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.
10 11 12 |
# File 'lib/ralyxa/skill.rb', line 10 def initialize(request) @request = request end |
Class Method Details
.handle(request, alexa_request_wrapper = Ralyxa::RequestEntities::Request) ⇒ Object
26 27 28 |
# File 'lib/ralyxa/skill.rb', line 26 def handle(request, alexa_request_wrapper = Ralyxa::RequestEntities::Request) new(alexa_request_wrapper.new(request)).handle end |
.handlers ⇒ Object
30 31 32 |
# File 'lib/ralyxa/skill.rb', line 30 def handlers @handlers.dup end |
.intent(intent_name, handler_base_class = Ralyxa::Handler, &intent_block) ⇒ Object
20 21 22 23 24 |
# File 'lib/ralyxa/skill.rb', line 20 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
14 15 16 17 |
# File 'lib/ralyxa/skill.rb', line 14 def handle handler = self.class.handlers[@request.intent_name] handler ? handler.new(@request).handle : warn(handler_not_found) end |