Class: Adhearsion::Rayo::Command::Reject

Inherits:
Adhearsion::Rayo::CommandNode show all
Includes:
HasHeaders
Defined in:
lib/adhearsion/rayo/command/reject.rb

Constant Summary collapse

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

Instance Attribute Summary

Attributes inherited from RayoNode

#client, #connection, #original_component

Instance Method Summary collapse

Methods included from HasHeaders

#headers=

Methods inherited from Adhearsion::Rayo::CommandNode

#initialize, #response, #response=

Methods inherited from RayoNode

#==, class_from_registration, from_xml, #inspect, #rayo_attributes, register, #source, #to_rayo, #to_xml

Constructor Details

This class inherits a constructor from Adhearsion::Rayo::CommandNode

Instance Method Details

#inherit(xml_node) ⇒ Object


26
27
28
29
30
31
# File 'lib/adhearsion/rayo/command/reject.rb', line 26

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

#rayo_children(root) ⇒ Object


33
34
35
36
# File 'lib/adhearsion/rayo/command/reject.rb', line 33

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

#reasonSymbol

Returns the reason type for rejecting a call. One of :busy, :dclined or :error.

Returns:

  • (Symbol)

    the reason type for rejecting a call. One of :busy, :dclined or :error.


18
# File 'lib/adhearsion/rayo/command/reject.rb', line 18

attribute :reason, Symbol

#reason=(reject_reason) ⇒ Object


19
20
21
22
23
24
# File 'lib/adhearsion/rayo/command/reject.rb', line 19

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