Sha256: c4cacf49df4f767e7bd7187a4fed914d069053d338976b3c819912d27d2d57f7

Contents?: true

Size: 1.38 KB

Versions: 48

Compression:

Stored size: 1.38 KB

Contents

module Blather
class Stanza

  # # PubSubOwner Base Class
  #
  # [XEP-0060 - Publish-Subscribe](http://xmpp.org/extensions/xep-0060.html)
  #
  # @handler :pubsub_owner
  class PubSubOwner < Iq
    register :pubsub_owner, :pubsub, 'http://jabber.org/protocol/pubsub#owner'

    # Creates the proper class from the stana's child
    # @private
    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

    # Overrides the parent to ensure a pubsub node is created
    # @private
    def self.new(type = nil, host = nil)
      new_node = super type
      new_node.to = host
      new_node.pubsub
      new_node
    end

    # Overrides the parent to ensure the pubsub node is destroyed
    # @private
    def inherit(node)
      remove_children :pubsub
      super
    end

    # Get or create the pubsub node on the stanza
    #
    # @return [Blather::XMPPNode]
    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  # PubSubOwner

end  # Stanza
end  # Blather

Version data entries

48 entries across 48 versions & 3 rubygems

Version Path
blather-2.0.0 lib/blather/stanza/pubsub_owner.rb
blather-1.2.0 lib/blather/stanza/pubsub_owner.rb
blather-1.1.4 lib/blather/stanza/pubsub_owner.rb
blather-1.1.3 lib/blather/stanza/pubsub_owner.rb
blather-1.1.2 lib/blather/stanza/pubsub_owner.rb
blather-1.1.1 lib/blather/stanza/pubsub_owner.rb
blather-1.1.0 lib/blather/stanza/pubsub_owner.rb
blather-1.0.0 lib/blather/stanza/pubsub_owner.rb
blather-0.8.8 lib/blather/stanza/pubsub_owner.rb
blather-0.8.7 lib/blather/stanza/pubsub_owner.rb
blather-0.8.6 lib/blather/stanza/pubsub_owner.rb
blather-0.8.5 lib/blather/stanza/pubsub_owner.rb
blather-0.8.4 lib/blather/stanza/pubsub_owner.rb
blather-0.8.3 lib/blather/stanza/pubsub_owner.rb
blather-0.8.2 lib/blather/stanza/pubsub_owner.rb
tp-blather-0.8.5 lib/blather/stanza/pubsub_owner.rb
tp-blather-0.8.4 lib/blather/stanza/pubsub_owner.rb
tp-blather-0.8.3 lib/blather/stanza/pubsub_owner.rb
tp-blather-0.8.2 lib/blather/stanza/pubsub_owner.rb
blather-0.8.1 lib/blather/stanza/pubsub_owner.rb