lib/blather/stanza/presence/status.rb in blather-0.7.1 vs lib/blather/stanza/presence/status.rb in blather-0.8.0
- old
+ new
@@ -75,10 +75,11 @@
#
# @handler :status
class Status < Presence
# @private
VALID_STATES = [:away, :chat, :dnd, :xa].freeze
+ VALID_TYPES = [:unavailable].freeze
include Comparable
register :status, :status
@@ -128,21 +129,10 @@
# @return [true, false]
def xa?
self.state == :xa
end
- # Set the type attribute
- # Ensures type is nil or :unavailable
- #
- # @param [<:unavailable, nil>] type the type
- def type=(type)
- if type && type.to_sym != :unavailable
- raise ArgumentError, "Invalid type (#{type}). Must be nil or unavailable"
- end
- super
- end
-
# Set the state
# Ensure state is one of :available, :away, :chat, :dnd, :xa or nil
#
# @param [<:available, :away, :chat, :dnd, :xa, nil>] state
def state=(state) # :nodoc:
@@ -201,11 +191,13 @@
# Raises an error if the JIDs aren't the same
#
# @param [Blather::Stanza::Presence::Status] o
# @return [true,false]
def <=>(o)
- unless self.from && o.from && self.from.stripped == o.from.stripped
- raise ArgumentError, "Cannot compare status from different JIDs: #{[self.from, o.from].inspect}"
+ if self.from || o.from
+ unless self.from.stripped == o.from.stripped
+ raise ArgumentError, "Cannot compare status from different JIDs: #{[self.from, o.from].inspect}"
+ end
end
if (self.type.nil? && o.type.nil?) || (!self.type.nil? && !o.type.nil?)
self.priority <=> o.priority
elsif self.type.nil? && !o.type.nil?