Sha256: d337a35d9871645810f3b691218a58f627ee74a88cee7cbdd3072e814c6f6e96
Contents?: true
Size: 906 Bytes
Versions: 2
Compression:
Stored size: 906 Bytes
Contents
module Blather class Stanza ## # Base Iq stanza class Iq < Stanza VALID_TYPES = [:get, :set, :result, :error] register :iq def self.import(node) klass = nil node.children.each { |e| break if klass = class_from_registration(e.element_name, (e.namespace.href if e.namespace)) } if klass && klass != self klass.import(node) else new(node[:type]).inherit(node) end end def self.new(type = nil, to = nil, id = nil) node = super :iq node.type = type || :get node.to = to node.id = id || self.next_id node end attribute_helpers_for :type, VALID_TYPES ## # Ensures type is :get, :set, :result or :error def type=(type) raise ArgumentError, "Invalid Type (#{type}), use: #{VALID_TYPES*' '}" if type && !VALID_TYPES.include?(type.to_sym) super end end end #Stanza end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
sprsquish-blather-0.4.1 | lib/blather/stanza/iq.rb |
blather-0.4.1 | lib/blather/stanza/iq.rb |