Class: Punchblock::Component::Asterisk::AMI::Action
- Inherits:
-
ComponentNode
- Object
- Niceogiri::XML::Node
- RayoNode
- Punchblock::CommandNode
- ComponentNode
- Punchblock::Component::Asterisk::AMI::Action
- Defined in:
- lib/punchblock/component/asterisk/ami/action.rb
Defined Under Namespace
Constant Summary
Constants inherited from RayoNode
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
-
#inspect_attributes ⇒ Object
:nodoc:.
- #name ⇒ Object
- #name=(other) ⇒ Object
-
#params ⇒ Array[Param]
Params.
- #params=(params) ⇒ Object
-
#params_hash ⇒ Hash
Hash of key-value pairs of params.
Methods inherited from ComponentNode
#add_event, #complete_event, #complete_event=, #initialize, #register_event_handler, #register_internal_handlers, #response=, #stop!, #stop_action, #trigger_event_handler, #write_action
Methods inherited from Punchblock::CommandNode
#initialize, #response, #response=, #write_attr
Methods inherited from RayoNode
class_from_registration, #eql?, import, #inspect, register, #source
Constructor Details
This class inherits a constructor from Punchblock::Component::ComponentNode
Class Method Details
.new(options = {}) ⇒ Object
12 13 14 15 16 |
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 12 def self.new( = {}) super().tap do |new_node| .each_pair { |k,v| new_node.send :"#{k}=", v } end end |
Instance Method Details
#inspect_attributes ⇒ Object
:nodoc:
57 58 59 |
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 57 def inspect_attributes # :nodoc: [:name, :params] + super end |
#name ⇒ Object
18 19 20 |
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 18 def name read_attr :name end |
#name=(other) ⇒ Object
22 23 24 |
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 22 def name=(other) write_attr :name, other end |
#params ⇒ Array[Param]
Returns params.
39 40 41 42 43 |
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 39 def params find('//ns:param', :ns => self.class.registered_ns).map do |i| Param.new i end end |
#params=(params) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 48 def params=(params) find('//ns:param', :ns => self.class.registered_ns).each(&:remove) if params.is_a? Hash params.each_pair { |k,v| self << Param.new(k, v) } elsif params.is_a? Array [params].flatten.each { |i| self << Param.new(i) } end end |
#params_hash ⇒ Hash
Returns hash of key-value pairs of params.
29 30 31 32 33 34 |
# File 'lib/punchblock/component/asterisk/ami/action.rb', line 29 def params_hash params.inject({}) do |hash, param| hash[param.name.downcase.gsub('-', '_').to_sym] = param.value hash end end |