Class: Blather::Stanza::PubSubOwner

Inherits:
Iq show all
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)

Direct Known Subclasses

Delete, Purge

Defined Under Namespace

Classes: Delete, Purge

Constant Summary

Constants inherited from Iq

Iq::VALID_TYPES

Constants inherited from XMPPNode

XMPPNode::BASE_NAMES

Instance Attribute Summary

Attributes inherited from Blather::Stanza

#handler_hierarchy

Class Method Summary collapse

Instance Method Summary collapse

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

#pubsubBlather::XMPPNode

Get or create the pubsub node on the stanza

Returns:



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