Sha256: bce5959148f4cd43bc538976a110d4b519e1859261392a424513030551ca2e17

Contents?: true

Size: 1.77 KB

Versions: 26

Compression:

Stored size: 1.77 KB

Contents

module Blather
class Stanza
class PubSub

  # # PubSub Create Stanza
  #
  # [XEP-0060 Section 8.1 - Create a Node](http://xmpp.org/extensions/xep-0060.html#owner-create)
  #
  # @handler :pubsub_create
  class Create < PubSub
    register :pubsub_create, :create, self.registered_ns

    # Create a new Create Stanza
    #
    # @param [<Blather::Stanza::Iq::VALID_TYPES>] type the node type
    # @param [String, nil] host the host to send the request to
    # @param [String, nil] node the name of the node to create
    def self.new(type = :set, host = nil, node = nil)
      new_node = super(type, host)
      new_node.create_node
      new_node.configure_node
      new_node.node = node
      new_node
    end

    # Get the name of the node to create
    #
    # @return [String, nil]
    def node
      create_node[:node]
    end

    # Set the name of the node to create
    #
    # @param [String, nil] node
    def node=(node)
      create_node[:node] = node
    end

    # Get or create the actual create node on the stanza
    #
    # @return [Balther::XMPPNode]
    def create_node
      unless create_node = pubsub.find_first('ns:create', :ns => self.class.registered_ns)
        self.pubsub << (create_node = XMPPNode.new('create', self.document))
        create_node.namespace = self.pubsub.namespace
      end
      create_node
    end

    # Get or create the actual configure node on the stanza
    #
    # @return [Blather::XMPPNode]
    def configure_node
      unless configure_node = pubsub.find_first('ns:configure', :ns => self.class.registered_ns)
        self.pubsub << (configure_node = XMPPNode.new('configure', self.document))
        configure_node.namespace = self.pubsub.namespace
      end
      configure_node
    end
  end  # Create

end  # PubSub
end  # Stanza
end  # Blather

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
blather-0.7.0 lib/blather/stanza/pubsub/create.rb
blather-0.6.2 lib/blather/stanza/pubsub/create.rb
blather-0.6.1 lib/blather/stanza/pubsub/create.rb
blather-0.6.0 lib/blather/stanza/pubsub/create.rb
blather-0.5.12 lib/blather/stanza/pubsub/create.rb
blather-0.5.11 lib/blather/stanza/pubsub/create.rb
blather-0.5.10 lib/blather/stanza/pubsub/create.rb
blather-0.5.9 lib/blather/stanza/pubsub/create.rb
blather-0.5.8 lib/blather/stanza/pubsub/create.rb
blather-0.5.7 lib/blather/stanza/pubsub/create.rb
blather-0.5.6 lib/blather/stanza/pubsub/create.rb
blather-0.5.4 lib/blather/stanza/pubsub/create.rb
blather-0.5.3 lib/blather/stanza/pubsub/create.rb
blather-0.5.2 lib/blather/stanza/pubsub/create.rb
blather-0.5.0 lib/blather/stanza/pubsub/create.rb
blather-0.4.16 lib/blather/stanza/pubsub/create.rb
blather-0.4.15 lib/blather/stanza/pubsub/create.rb
shingara-blather-0.4.14 lib/blather/stanza/pubsub/create.rb
blather-0.4.14 lib/blather/stanza/pubsub/create.rb
blather-0.4.13 lib/blather/stanza/pubsub/create.rb