Class: Punchblock::RayoNode
- Inherits:
-
Niceogiri::XML::Node
- Object
- Niceogiri::XML::Node
- Punchblock::RayoNode
- Defined in:
- lib/punchblock/rayo_node.rb
Direct Known Subclasses
CommandNode, Component::Asterisk::AGI::Command::Param, Component::Asterisk::AMI::Action::Complete::Attribute, Component::Asterisk::AMI::Action::Param, Component::Input::Grammar, Event, Event::Asterisk::AMI::Event::Attribute, Event::Complete::Reason, Header, MediaNode, Ref
Constant Summary
- @@registrations =
{}
Instance Attribute Summary (collapse)
-
- (Object) client
Returns the value of attribute client.
-
- (Object) component_id
Returns the value of attribute component_id.
-
- (Object) connection
Returns the value of attribute connection.
-
- (Object) domain
Returns the value of attribute domain.
-
- (Object) original_component
Returns the value of attribute original_component.
-
- (Object) target_call_id
Returns the value of attribute target_call_id.
-
- (Object) target_mixer_name
Returns the value of attribute target_mixer_name.
Class Method Summary (collapse)
-
+ (Class?) class_from_registration(name, ns = nil)
Find the class to use given the name and namespace of a stanza.
-
+ (Object) import(node, call_id = nil, component_id = nil)
Import an XML::Node to the appropriate class.
-
+ (Object) new(name = registered_name, doc = nil)
Create a new Node object.
-
+ (Object) register(name, ns = nil)
Register a new stanza class to a name and/or namespace.
Instance Method Summary (collapse)
- - (Boolean) eql?(o, *fields)
- - (Object) inspect (also: #to_s)
-
- (Object) inspect_attributes
:nodoc:.
-
- (RayoNode) source
The original command issued that lead to this event.
Instance Attribute Details
- (Object) client
Returns the value of attribute client
12 13 14 |
# File 'lib/punchblock/rayo_node.rb', line 12 def client @client end |
- (Object) component_id
Returns the value of attribute component_id
12 13 14 |
# File 'lib/punchblock/rayo_node.rb', line 12 def component_id @component_id end |
- (Object) connection
Returns the value of attribute connection
12 13 14 |
# File 'lib/punchblock/rayo_node.rb', line 12 def connection @connection end |
- (Object) domain
Returns the value of attribute domain
12 13 14 |
# File 'lib/punchblock/rayo_node.rb', line 12 def domain @domain end |
- (Object) original_component
Returns the value of attribute original_component
12 13 14 |
# File 'lib/punchblock/rayo_node.rb', line 12 def original_component @original_component end |
- (Object) target_call_id
Returns the value of attribute target_call_id
12 13 14 |
# File 'lib/punchblock/rayo_node.rb', line 12 def target_call_id @target_call_id end |
- (Object) target_mixer_name
Returns the value of attribute target_mixer_name
12 13 14 |
# File 'lib/punchblock/rayo_node.rb', line 12 def target_mixer_name @target_mixer_name end |
Class Method Details
+ (Class?) class_from_registration(name, ns = nil)
Find the class to use given the name and namespace of a stanza
33 34 35 |
# File 'lib/punchblock/rayo_node.rb', line 33 def self.class_from_registration(name, ns = nil) @@registrations[[name.to_s, ns]] end |
+ (Object) import(node, call_id = nil, component_id = nil)
Import an XML::Node to the appropriate class
Looks up the class the node should be then creates it based on the elements of the XML::Node
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/punchblock/rayo_node.rb', line 43 def self.import(node, call_id = nil, component_id = nil) ns = (node.namespace.href if node.namespace) klass = class_from_registration(node.element_name, ns) if klass && klass != self klass.import node, call_id, component_id else new.inherit node end.tap do |event| event.target_call_id = call_id event.component_id = component_id end end |
+ (Object) new(name = registered_name, doc = nil)
Create a new Node object
not provided one will be created
62 63 64 |
# File 'lib/punchblock/rayo_node.rb', line 62 def self.new(name = registered_name, doc = nil) super name, doc, registered_ns end |
+ (Object) register(name, ns = nil)
Register a new stanza class to a name and/or namespace
This registers a namespace that is used when looking up the class name of the object to instantiate when a new stanza is received
22 23 24 25 26 |
# File 'lib/punchblock/rayo_node.rb', line 22 def self.register(name, ns = nil) self.registered_name = name.to_s self.registered_ns = ns.is_a?(Symbol) ? RAYO_NAMESPACES[ns] : ns @@registrations[[self.registered_name, self.registered_ns]] = self end |
Instance Method Details
- (Boolean) eql?(o, *fields)
74 75 76 |
# File 'lib/punchblock/rayo_node.rb', line 74 def eql?(o, *fields) super o, *(fields + inspect_attributes) end |
- (Object) inspect Also known as: to_s
70 71 72 |
# File 'lib/punchblock/rayo_node.rb', line 70 def inspect "#<#{self.class} #{inspect_attributes.map { |c| "#{c}=#{self.__send__(c).inspect rescue nil}" }.compact * ', '}>" end |
- (Object) inspect_attributes
:nodoc:
66 67 68 |
# File 'lib/punchblock/rayo_node.rb', line 66 def inspect_attributes # :nodoc: [:target_call_id, :component_id, :target_mixer_name] end |
- (RayoNode) source
The original command issued that lead to this event
81 82 83 84 |
# File 'lib/punchblock/rayo_node.rb', line 81 def source @source ||= client.find_component_by_id component_id if client && component_id @source ||= original_component end |