Class: Blather::Stanza::Iq::Query

Inherits:
Blather::Stanza::Iq show all
Defined in:
lib/blather/stanza/iq/query.rb

Overview

# 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

Direct Known Subclasses

Disco, Roster, S5b

Constant Summary

Constants inherited from Blather::Stanza::Iq

VALID_TYPES

Constants inherited from XMPPNode

XMPPNode::BASE_NAMES

Instance Attribute Summary

Attributes inherited from Blather::Stanza

#handler_hierarchy

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Blather::Stanza::Iq

#error?, #get?, import, #reply!, #result?, #set?, #type=

Methods inherited from Blather::Stanza

#as_error, #error?, #from, #from=, handler_list, #id, #id=, #initialize, next_id, register, #reply, #reply!, #to, #to=, #type, #type=

Methods inherited from XMPPNode

class_from_registration, #decorate, decorator_modules, import, parse, register, #to_stanza

Constructor Details

This class inherits a constructor from Blather::Stanza

Class Method Details

.new(type = nil) ⇒ Object

Overrides the parent method to ensure a query node is created



17
18
19
20
21
# File 'lib/blather/stanza/iq/query.rb', line 17

def self.new(type = nil)
  node = super
  node.query
  node
end

Instance Method Details

#inherit(node) ⇒ Object

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

See Also:

  • Blather::Stanza::Iq#inherit


26
27
28
29
# File 'lib/blather/stanza/iq/query.rb', line 26

def inherit(node)
  query.remove
  super
end

#queryBalather::XMPPNode

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

Returns:

  • (Balather::XMPPNode)


36
37
38
39
40
41
42
43
44
45
46
47
48
# 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