Sha256: 7b7691563c2eef62be2a531c7cd7c11da48346b54caf7270d4667000f4211c5e

Contents?: true

Size: 1.25 KB

Versions: 16

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8

module Punchblock
  module Command
    class Redirect < CommandNode
      register :redirect, :core

      include HasHeaders

      ##
      # Create a Rayo redirect command
      #
      # @param [Hash] options
      # @option options [String] :to redirect target
      # @option options [Array[Header], Hash, Optional] :headers SIP headers to attach to
      #   the new call. Can be either a hash of key-value pairs, or an array of
      #   Header objects.
      #
      # @return [Command::Redirect] a formatted Rayo redirect command
      #
      # @example
      #    Redirect.new(:to => 'tel:+14045551234').to_xml
      #
      #    returns:
      #        <redirect to="tel:+14045551234" xmlns="urn:xmpp:rayo:1"/>
      #
      def self.new(options = {})
        super().tap do |new_node|
          new_node.to = options[:to]
          new_node.headers = options[:headers]
        end
      end

      ##
      # @return [String] the redirect target
      def to
        read_attr :to
      end

      ##
      # @param [String] redirect_to redirect target
      def to=(redirect_to)
        write_attr :to, redirect_to
      end

      def inspect_attributes # :nodoc:
        [:to] + super
      end
    end # Redirect
  end # Command
end # Punchblock

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
punchblock-1.9.4 lib/punchblock/command/redirect.rb
punchblock-1.9.3 lib/punchblock/command/redirect.rb
punchblock-1.9.2 lib/punchblock/command/redirect.rb
punchblock-1.9.1 lib/punchblock/command/redirect.rb
punchblock-1.9.0 lib/punchblock/command/redirect.rb
punchblock-1.8.2 lib/punchblock/command/redirect.rb
punchblock-1.8.1 lib/punchblock/command/redirect.rb
punchblock-1.8.0 lib/punchblock/command/redirect.rb
punchblock-1.7.1 lib/punchblock/command/redirect.rb
punchblock-1.7.0 lib/punchblock/command/redirect.rb
punchblock-1.6.1 lib/punchblock/command/redirect.rb
punchblock-1.6.0 lib/punchblock/command/redirect.rb
punchblock-1.5.3 lib/punchblock/command/redirect.rb
punchblock-1.5.2 lib/punchblock/command/redirect.rb
punchblock-1.5.1 lib/punchblock/command/redirect.rb
punchblock-1.5.0 lib/punchblock/command/redirect.rb