class Blather::Stanza::PubSubOwner

# PubSubOwner Base Class

[XEP-0060 - Publish-Subscribe](xmpp.org/extensions/xep-0060.html)

@handler :pubsub_owner

Public Class Methods

import(node) click to toggle source

Creates the proper class from the stana's child @private

# 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) click to toggle source

Overrides the parent to ensure a pubsub node is created @private

Calls superclass method Blather::Stanza::Iq::new
# 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

Public Instance Methods

inherit(node) click to toggle source

Overrides the parent to ensure the pubsub node is destroyed @private

Calls superclass method
# File lib/blather/stanza/pubsub_owner.rb, line 33
def inherit(node)
  remove_children :pubsub
  super
end
pubsub() click to toggle source

Get or create the pubsub node on the stanza

@return [Blather::XMPPNode]

# 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