Sha256: b5ebdf854a69a8e81a062246160ebdc59c65ae49c89365219cd3da5dc0bc2689

Contents?: true

Size: 1.15 KB

Versions: 33

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

33 entries across 33 versions & 3 rubygems

Version Path
tp-blather-0.8.5 lib/blather/stanza/iq/query.rb
tp-blather-0.8.4 lib/blather/stanza/iq/query.rb
tp-blather-0.8.3 lib/blather/stanza/iq/query.rb
tp-blather-0.8.2 lib/blather/stanza/iq/query.rb
blather-0.8.1 lib/blather/stanza/iq/query.rb
blather-0.8.0 lib/blather/stanza/iq/query.rb
blather-0.7.1 lib/blather/stanza/iq/query.rb
blather-0.7.0 lib/blather/stanza/iq/query.rb
blather-0.6.2 lib/blather/stanza/iq/query.rb
blather-0.6.1 lib/blather/stanza/iq/query.rb
blather-0.6.0 lib/blather/stanza/iq/query.rb
blather-0.5.12 lib/blather/stanza/iq/query.rb
blather-0.5.11 lib/blather/stanza/iq/query.rb
blather-0.5.10 lib/blather/stanza/iq/query.rb
blather-0.5.9 lib/blather/stanza/iq/query.rb
blather-0.5.8 lib/blather/stanza/iq/query.rb
blather-0.5.7 lib/blather/stanza/iq/query.rb
blather-0.5.6 lib/blather/stanza/iq/query.rb
blather-0.5.4 lib/blather/stanza/iq/query.rb
blather-0.5.3 lib/blather/stanza/iq/query.rb