Sha256: 36a4bd128e17ce1a4e7a7d5d062a661f6ebf5a43a7e2743b67600fec91ba6d54

Contents?: true

Size: 687 Bytes

Versions: 6

Compression:

Stored size: 687 Bytes

Contents

require_relative './request'
require_relative './response'
require_relative './handler'

module Ralyxa
  class Skill
    @@intents = {}

    def initialize(request)
      @request = request
    end

    def handle(handler = Ralyxa::Handler)
      intent_proc = self.class.registered_intents[@request.intent_name]
      handler.new(@request, intent_proc).handle
    end

    class << self
      def intent(intent_name, &block)
        @@intents[intent_name] = block
      end

      def registered_intents
        @@intents.dup
      end

      def handle(request, alexa_request_wrapper = Ralyxa::Request)
        new(alexa_request_wrapper.new(request)).handle
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ralyxa-1.4.0 lib/ralyxa/skill.rb
ralyxa-1.3.0 lib/ralyxa/skill.rb
ralyxa-1.2.0 lib/ralyxa/skill.rb
ralyxa-1.1.1 lib/ralyxa/skill.rb
ralyxa-1.1.0 lib/ralyxa/skill.rb
ralyxa-1.0.0 lib/ralyxa/skill.rb