Sha256: 03cba053ceede97a7cd0ac1d53a42dd16fab5cf33b361f5bdc8059e23fa833bc

Contents?: true

Size: 1.25 KB

Versions: 9

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8

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

      include HasHeaders

      ##
      # Create an Rayo redirect message
      #
      # @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

9 entries across 9 versions & 1 rubygems

Version Path
punchblock-1.4.1 lib/punchblock/command/redirect.rb
punchblock-1.4.0 lib/punchblock/command/redirect.rb
punchblock-1.3.0 lib/punchblock/command/redirect.rb
punchblock-1.2.0 lib/punchblock/command/redirect.rb
punchblock-1.1.0 lib/punchblock/command/redirect.rb
punchblock-1.0.0 lib/punchblock/command/redirect.rb
punchblock-0.12.0 lib/punchblock/command/redirect.rb
punchblock-0.11.0 lib/punchblock/command/redirect.rb
punchblock-0.10.0 lib/punchblock/command/redirect.rb