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

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Iq

#type=

Methods inherited from Blather::Stanza

#as_error, attribute_helpers_for, #from, handler_list, next_id, register, #reply, #reply!, #to

Methods inherited from XMPPNode

attribute_accessor, attribute_reader, attribute_writer, class_from_registration, content_attr_accessor, content_attr_reader, content_attr_writer, #content_from, #inherit_attrs, #namespace=, #namespace_href, #nokogiri_namespace=, register, #remove_child, #remove_children, #set_content_for, #to_stanza

Methods inherited from Nokogiri::XML::Node

#[]=, #attr_set, #find_first, #nokogiri_xpath, #xpath

Class Method Details

.import(node) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/blather/stanza/pubsub_owner.rb', line 7

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

Ensure the namespace is set to the query node



17
18
19
20
21
22
# File 'lib/blather/stanza/pubsub_owner.rb', line 17

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

Kill the pubsub node before running inherit



26
27
28
29
# File 'lib/blather/stanza/pubsub_owner.rb', line 26

def inherit(node)
  remove_children :pubsub
  super
end

#pubsubObject



31
32
33
34
35
36
37
# File 'lib/blather/stanza/pubsub_owner.rb', line 31

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