Sha256: b97d98d951d735277b1d28e8027500237f78e357f9101f864d504a24b906511a

Contents?: true

Size: 907 Bytes

Versions: 24

Compression:

Stored size: 907 Bytes

Contents

# encoding: utf-8

module Punchblock
  module Command
    class Reject < CommandNode
      register :reject, :core

      include HasHeaders

      VALID_REASONS = [:busy, :decline, :error].freeze

      # @return [Symbol] the reason type for rejecting a call. One of :busy, :dclined or :error.
      # @raises ArgumentError if reject_reason is not one of the allowed reasons
      attribute :reason, Symbol
      def reason=(reject_reason)
        if reject_reason && !VALID_REASONS.include?(reject_reason.to_sym)
          raise ArgumentError, "Invalid Reason (#{reject_reason}), use: #{VALID_REASONS*' '}"
        end
        super
      end

      def inherit(xml_node)
        if first_child = xml_node.at_xpath('*')
          self.reason = first_child.name
        end
        super
      end

      def rayo_children(root)
        root.send reason if reason
        super
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
punchblock-2.7.5 lib/punchblock/command/reject.rb
punchblock-2.7.3 lib/punchblock/command/reject.rb
punchblock-2.7.2 lib/punchblock/command/reject.rb
punchblock-2.7.1 lib/punchblock/command/reject.rb
punchblock-2.7.0 lib/punchblock/command/reject.rb
punchblock-2.6.0 lib/punchblock/command/reject.rb
punchblock-2.5.3 lib/punchblock/command/reject.rb
punchblock-2.5.2 lib/punchblock/command/reject.rb
punchblock-2.5.1 lib/punchblock/command/reject.rb
punchblock-2.5.0 lib/punchblock/command/reject.rb
punchblock-2.4.2 lib/punchblock/command/reject.rb
punchblock-2.4.0 lib/punchblock/command/reject.rb
punchblock-2.3.1 lib/punchblock/command/reject.rb
punchblock-2.3.0 lib/punchblock/command/reject.rb
punchblock-2.2.2 lib/punchblock/command/reject.rb
punchblock-2.2.1 lib/punchblock/command/reject.rb
punchblock-2.2.0 lib/punchblock/command/reject.rb
punchblock-2.1.1 lib/punchblock/command/reject.rb
punchblock-2.1.0 lib/punchblock/command/reject.rb
punchblock-2.0.2 lib/punchblock/command/reject.rb