Sha256: 930b7fd67cbd0452c693cee84e6533f1115c01371c3c59742652f69297857274

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module TwilioBase
  module Routers
    module Voice
      class Base
        include Rails.application.routes.url_helpers

        delegate :action_url,
          :caller_uuid,
          :endpoint,
          :name,
          :routing_attributes,
          :routing_method,
          :status_callback_events,
          :status_callback_url,
          :timeout,
          to: :protocol

        def initialize(protocol:)
          self.protocol = protocol
        end

        def route
          yield_response = yield if block_given?

          vr = yield_response || voice_response

          vr.public_send(routing_method, routing_attributes) do |router|
            router.public_send(
              name,
              endpoint,
              status_callback_event: status_callback_events,
              status_callback: status_callback_url
            )
          end.to_s
        end

        private

        attr_accessor :protocol

        def voice_response
          @voice_response ||= Twilio::TwiML::VoiceResponse.new
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twilio_base-1.11.1101 app/services/twilio_base/routers/voice/base.rb
twilio_base-1.11.11 app/services/twilio_base/routers/voice/base.rb