Class: Blather::Stanza::PubSubOwner
- Inherits:
-
Iq
- Object
- Niceogiri::XML::Node
- XMPPNode
- Blather::Stanza
- Iq
- Blather::Stanza::PubSubOwner
- Defined in:
- lib/blather/stanza/pubsub_owner.rb,
lib/blather/stanza/pubsub_owner/purge.rb,
lib/blather/stanza/pubsub_owner/delete.rb
Overview
# PubSubOwner Base Class
[XEP-0060 - Publish-Subscribe](xmpp.org/extensions/xep-0060.html)
Defined Under Namespace
Constant Summary
Constants inherited from Iq
Constants inherited from XMPPNode
Instance Attribute Summary
Attributes inherited from Blather::Stanza
Class Method Summary collapse
-
.import(node) ⇒ Object
Creates the proper class from the stana’s child.
-
.new(type = nil, host = nil) ⇒ Object
Overrides the parent to ensure a pubsub node is created.
Instance Method Summary collapse
-
#inherit(node) ⇒ Object
Overrides the parent to ensure the pubsub node is destroyed.
-
#pubsub ⇒ Blather::XMPPNode
Get or create the pubsub node on the stanza.
Methods inherited from Iq
#error?, #get?, #reply!, #result?, #set?, #type=
Methods inherited from Blather::Stanza
#as_error, #error?, #from, #from=, handler_list, #id, #id=, #initialize, next_id, register, #reply, #reply!, #to, #to=, #type, #type=
Methods inherited from XMPPNode
class_from_registration, #decorate, decorator_modules, parse, register, #to_stanza
Constructor Details
This class inherits a constructor from Blather::Stanza
Class Method Details
.import(node) ⇒ Object
Creates the proper class from the stana’s child
14 15 16 17 18 19 20 |
# File 'lib/blather/stanza/pubsub_owner.rb', line 14 def self.import(node) klass = nil if pubsub = node.document.find_first('//ns:pubsub', :ns => self.registered_ns) pubsub.children.each { |e| break if klass = class_from_registration(e.element_name, (e.namespace.href if e.namespace)) } end (klass || self).new(node[:type]).inherit(node) end |
.new(type = nil, host = nil) ⇒ Object
Overrides the parent to ensure a pubsub node is created
24 25 26 27 28 29 |
# File 'lib/blather/stanza/pubsub_owner.rb', line 24 def self.new(type = nil, host = nil) new_node = super type new_node.to = host new_node.pubsub new_node end |
Instance Method Details
#inherit(node) ⇒ Object
Overrides the parent to ensure the pubsub node is destroyed
33 34 35 36 |
# File 'lib/blather/stanza/pubsub_owner.rb', line 33 def inherit(node) remove_children :pubsub super end |
#pubsub ⇒ Blather::XMPPNode
Get or create the pubsub node on the stanza
41 42 43 44 45 46 47 |
# File 'lib/blather/stanza/pubsub_owner.rb', line 41 def pubsub unless p = find_first('ns:pubsub', :ns => self.class.registered_ns) self << (p = XMPPNode.new('pubsub', self.document)) p.namespace = self.class.registered_ns end p end |