class Blather::Stanza::Iq::Query

# 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

Public Class Methods

new(type = nil) click to toggle source

Overrides the parent method to ensure a query node is created

@see Blather::Stanza::Iq.new

Calls superclass method Blather::Stanza::Iq::new
# File lib/blather/stanza/iq/query.rb, line 17
def self.new(type = nil)
  node = super
  node.query
  node
end

Public Instance Methods

inherit(node) click to toggle source

Overrides the parent method to ensure the current query node is destroyed

@see Blather::Stanza::Iq#inherit

Calls superclass method
# File lib/blather/stanza/iq/query.rb, line 26
def inherit(node)
  query.remove
  super
end
query() click to toggle source

Query node accessor If a query node exists it will be returned. Otherwise a new node will be created and returned

@return [Balather::XMPPNode]

# File lib/blather/stanza/iq/query.rb, line 36
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