Sha256: b0274be7a97cfba110f10f98021ec2e90e3b8bc0f8cda4bc339dc92377c8e73d

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 KB

Contents

module Blather
class Stanza

  class PubSubOwner < Iq
    register :pubsub_owner, :pubsub, 'http://jabber.org/protocol/pubsub#owner'

    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

    ##
    # Ensure the namespace is set to the query node
    def self.new(type = nil, host = nil)
      new_node = super type
      new_node.to = host
      new_node.pubsub
      new_node
    end

    ##
    # Kill the pubsub node before running inherit
    def inherit(node)
      remove_children :pubsub
      super
    end

    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
  end

end #Stanza
end #Blather

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
sprsquish-blather-0.4.0 lib/blather/stanza/pubsub_owner.rb
sprsquish-blather-0.4.1 lib/blather/stanza/pubsub_owner.rb
sprsquish-blather-0.4.2 lib/blather/stanza/pubsub_owner.rb
sprsquish-blather-0.4.3 lib/blather/stanza/pubsub_owner.rb
sprsquish-blather-0.4.4 lib/blather/stanza/pubsub_owner.rb
blather-0.4.7 lib/blather/stanza/pubsub_owner.rb
blather-0.4.6 lib/blather/stanza/pubsub_owner.rb
blather-0.4.5 lib/blather/stanza/pubsub_owner.rb
blather-0.4.4 lib/blather/stanza/pubsub_owner.rb
blather-0.4.3 lib/blather/stanza/pubsub_owner.rb
blather-0.4.1 lib/blather/stanza/pubsub_owner.rb
blather-0.4.0 lib/blather/stanza/pubsub_owner.rb
blather-0.4.2 lib/blather/stanza/pubsub_owner.rb