Sha256: 3f028e38e76ccad5b526166b1bdee298597ac5fe8a1de6abbf02d5db81a4c7af

Contents?: true

Size: 877 Bytes

Versions: 1

Compression:

Stored size: 877 Bytes

Contents

module Blather
class Stanza
class Iq

  class Query < Iq
    register :query, :query

    ##
    # Ensure the namespace is set to the query node
    def self.new(type = nil)
      elem = super
      elem.query.xmlns = self.xmlns
      elem
    end

    ##
    # Kill the query node before running inherit
    def inherit(node)
      query.remove!
      @query = nil
      super
    end

    ##
    # Query node accessor
    # This will ensure there actually is a query node
    def query
      (self << (q = XMPPNode.new('query'))) unless q = find_first('query')
      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!
      self.type = :result
      super
    end
  end #Query

end #Iq
end #Stanza
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blather-0.2 lib/blather/stanza/iq/query.rb