Sha256: c7dfc050c3e4c9106f8b79ca4681ab70bad12667aacfe6ffa3d46a503e114d7c
Contents?: true
Size: 1.08 KB
Versions: 4
Compression:
Stored size: 1.08 KB
Contents
module Blather class Stanza ## # Base Presence stanza class Presence < Stanza VALID_TYPES = [:unavailable, :subscribe, :subscribed, :unsubscribe, :unsubscribed, :probe, :error] register :presence ## # Creates a class based on the presence type # either a Status or Subscription object is created based # on the type attribute. # If neither is found it instantiates a Presence object def self.import(node) klass = case node['type'] when nil, 'unavailable' then Status when /subscribe/ then Subscription else self end klass.new.inherit(node) end ## # Ensure element_name is "presence" for all subclasses def self.new super :presence end attribute_helpers_for(:type, VALID_TYPES) ## # Ensures type is one of :unavailable, :subscribe, :subscribed, :unsubscribe, :unsubscribed, :probe 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
4 entries across 4 versions & 2 rubygems