Class: Blather::Stanza::PubSub
- Inherits:
-
Iq
- Object
- Nokogiri::XML::Node
- XMPPNode
- Blather::Stanza
- Iq
- Blather::Stanza::PubSub
- Defined in:
- lib/blather/stanza/pubsub.rb,
lib/blather/stanza/pubsub/event.rb,
lib/blather/stanza/pubsub/items.rb,
lib/blather/stanza/pubsub/create.rb,
lib/blather/stanza/pubsub/publish.rb,
lib/blather/stanza/pubsub/retract.rb,
lib/blather/stanza/pubsub/subscribe.rb,
lib/blather/stanza/pubsub/unsubscribe.rb,
lib/blather/stanza/pubsub/affiliations.rb,
lib/blather/stanza/pubsub/subscription.rb,
lib/blather/stanza/pubsub/subscriptions.rb
Overview
# Pubsub Stanza
[XEP-0060 - Publish-Subscribe](xmpp.org/extensions/xep-0060.html)
The base class for all PubSub nodes. This provides helper methods common to all PubSub nodes.
Direct Known Subclasses
Affiliations, Create, Items, Publish, Retract, Subscribe, Subscription, Subscriptions, Unsubscribe, PubSubErrors
Defined Under Namespace
Classes: Affiliations, Create, Event, Items, Publish, Retract, Subscribe, Subscription, Subscriptions, Unsubscribe
Constant Summary
Constants inherited from Iq
Constants inherited from XMPPNode
Class Method Summary collapse
- .import(node) ⇒ Object
-
.new(type = nil, host = nil) ⇒ Object
Overwrites the parent constructor to ensure a pubsub node is present.
Instance Method Summary collapse
-
#inherit(node) ⇒ Object
Overrides the parent to ensure the current pubsub node is destroyed before inheritting the new content.
-
#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=, next_id, register, #reply, #reply!, #to, #to=, #type, #type=
Methods inherited from XMPPNode
class_from_registration, #content_from, #inherit_attrs, #inspect, #namespace=, #namespace_href, #nokogiri_namespace=, #read_attr, #read_content, register, #remove_child, #remove_children, #set_content_for, #to_stanza, #write_attr
Methods inherited from Nokogiri::XML::Node
#[]=, #attr_set, #find_first, #nokogiri_xpath, #xpath
Class Method Details
.import(node) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/blather/stanza/pubsub.rb', line 16 def self.import(node) klass = nil if pubsub = node.document.find_first('//ns:pubsub', :ns => self.registered_ns) pubsub.children.detect do |e| ns = e.namespace ? e.namespace.href : nil klass = class_from_registration(e.element_name, ns) end end (klass || self).new(node[:type]).inherit(node) end |
.new(type = nil, host = nil) ⇒ Object
Overwrites the parent constructor to ensure a pubsub node is present. Also allows the addition of a host attribute
32 33 34 35 36 37 |
# File 'lib/blather/stanza/pubsub.rb', line 32 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 current pubsub node is destroyed before inheritting the new content
43 44 45 46 |
# File 'lib/blather/stanza/pubsub.rb', line 43 def inherit(node) remove_children :pubsub super end |
#pubsub ⇒ Blather::XMPPNode
Get or create the pubsub node on the stanza
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/blather/stanza/pubsub.rb', line 51 def pubsub p = find_first('ns:pubsub', :ns => self.class.registered_ns) || find_first('pubsub', :ns => self.class.registered_ns) unless p self << (p = XMPPNode.new('pubsub', self.document)) p.namespace = self.class.registered_ns end p end |