Sha256: ff28d3bbb726ba62aedf900301f1528113ecaa2836c134e0fcd34d9ec15832c0

Contents?: true

Size: 1.03 KB

Versions: 13

Compression:

Stored size: 1.03 KB

Contents

module Blather
class Stanza
class Iq

  class Query < Iq
    register :query, :query

    ##
    # Ensure the query node is created
    def self.new(type = nil)
      node = super
      node.query
      node
    end

    ##
    # Kill the query node before running inherit
    def inherit(node)
      query.remove
      super
    end

    ##
    # Query node accessor
    # This will ensure there actually is a query node
    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

    ##
    # A query reply should have type set to "result"
    def reply
      elem = super
      elem.type = :result
      elem
    end

    ##
    # A query reply should have type set to "result"
    def reply!
      super
      self.type = :result
      self
    end
  end #Query

end #Iq
end #Stanza
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
sprsquish-blather-0.4.0 lib/blather/stanza/iq/query.rb
sprsquish-blather-0.4.1 lib/blather/stanza/iq/query.rb
sprsquish-blather-0.4.2 lib/blather/stanza/iq/query.rb
sprsquish-blather-0.4.3 lib/blather/stanza/iq/query.rb
sprsquish-blather-0.4.4 lib/blather/stanza/iq/query.rb
blather-0.4.7 lib/blather/stanza/iq/query.rb
blather-0.4.6 lib/blather/stanza/iq/query.rb
blather-0.4.5 lib/blather/stanza/iq/query.rb
blather-0.4.4 lib/blather/stanza/iq/query.rb
blather-0.4.3 lib/blather/stanza/iq/query.rb
blather-0.4.2 lib/blather/stanza/iq/query.rb
blather-0.4.1 lib/blather/stanza/iq/query.rb
blather-0.4.0 lib/blather/stanza/iq/query.rb