Class: Punchblock::Component::Asterisk::AMI::Action::Complete::Success
Constant Summary
Constants inherited
from RayoNode
RayoNode::InvalidNodeError
Instance Attribute Summary
Attributes inherited from RayoNode
#client, #component_id, #connection, #domain, #original_component, #target_call_id, #target_mixer_name
Class Method Summary
collapse
Instance Method Summary
collapse
#name
Methods inherited from RayoNode
class_from_registration, #eql?, import, #inspect, register, #source
Class Method Details
.new(options = {}) ⇒ Object
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 69
def self.new(options = {})
super().tap do |new_node|
case options
when Nokogiri::XML::Node
new_node.inherit options
else
options.each_pair { |k,v| new_node.send :"#{k}=", v }
end
end
end
|
Instance Method Details
#attributes ⇒ Array[Attribute]
115
116
117
118
119
|
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 115
def attributes
find('//ns:attribute', :ns => self.class.registered_ns).map do |i|
Attribute.new i
end
end
|
#attributes=(attributes) ⇒ Object
124
125
126
127
128
129
130
131
|
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 124
def attributes=(attributes)
find('//ns:attribute', :ns => self.class.registered_ns).each(&:remove)
if attributes.is_a? Hash
attributes.each_pair { |k,v| self << Attribute.new(k, v) }
elsif attributes.is_a? Array
[attributes].flatten.each { |i| self << Attribute.new(i) }
end
end
|
#attributes_hash ⇒ Hash
Returns hash of key-value pairs of attributes.
105
106
107
108
109
110
|
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 105
def attributes_hash
attributes.inject({}) do |hash, attribute|
hash[attribute.name.downcase.gsub('-', '_').to_sym] = attribute.value
hash
end
end
|
#inspect_attributes ⇒ Object
133
134
135
|
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 133
def inspect_attributes
[:message, :attributes_hash]
end
|
94
95
96
|
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 94
def message
message_node.text
end
|
#message=(other) ⇒ Object
98
99
100
|
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 98
def message=(other)
message_node.content = other
end
|
#message_node ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 80
def message_node
mn = if self.class.registered_ns
find_first 'ns:message', :ns => self.class.registered_ns
else
find_first 'message'
end
unless mn
self << (mn = RayoNode.new('message', self.document))
mn.namespace = self.class.registered_ns
end
mn
end
|