Sha256: ac9d1fcd5dc3b60822ef71c1678c121ef10571e112841354d1e47c7ba36cccfb

Contents?: true

Size: 1.15 KB

Versions: 15

Compression:

Stored size: 1.15 KB

Contents

module Blather
class Stanza
class Iq

  # # Query Stanza
  #
  # This is a base class for any query based Iq stanzas. It provides a base set
  # of methods for working with query stanzas
  #
  # @handler :query
  class Query < Iq
    register :query, :query

    # Overrides the parent method to ensure a query node is created
    #
    # @see Blather::Stanza::Iq.new
    def self.new(type = nil)
      node = super
      node.query
      node
    end

    # Overrides the parent method to ensure the current query node is destroyed
    #
    # @see Blather::Stanza::Iq#inherit
    def inherit(node)
      query.remove
      super
    end

    # Query node accessor
    # If a query node exists it will be returned.
    # Otherwise a new node will be created and returned
    #
    # @return [Balather::XMPPNode]
    def query
      q = if self.class.registered_ns
        find_first('query_ns:query', :query_ns => self.class.registered_ns)
      else
        find_first('query')
      end

      unless q
        (self << (q = XMPPNode.new('query', self.document)))
        q.namespace = self.class.registered_ns
      end
      q
    end
  end #Query

end #Iq
end #Stanza
end

Version data entries

15 entries across 15 versions & 1 rubygems

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