Class: Punchblock::Command::Reject

Inherits:
Punchblock::CommandNode show all
Includes:
HasHeaders
Defined in:
lib/punchblock/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=, included

Methods inherited from Punchblock::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 Punchblock::CommandNode

Instance Method Details

#inherit(xml_node) ⇒ Object


22
23
24
25
26
27
# File 'lib/punchblock/command/reject.rb', line 22

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

#rayo_children(root) ⇒ Object


29
30
31
32
# File 'lib/punchblock/command/reject.rb', line 29

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

#reasonSymbol


14
# File 'lib/punchblock/command/reject.rb', line 14

attribute :reason, Symbol

#reason=(reject_reason) ⇒ Object


15
16
17
18
19
20
# File 'lib/punchblock/command/reject.rb', line 15

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