class Qs::Event
Constants
- InvalidError
- PAYLOAD_TYPE
Attributes
channel[R]
name[R]
published_at[R]
publisher[R]
Public Class Methods
new(channel, name, options = nil)
click to toggle source
Calls superclass method
# File lib/qs/event.rb, line 11 def initialize(channel, name, options = nil) options ||= {} options[:params] ||= {} validate!(channel, name, options[:params]) @channel = channel @name = name @publisher = options[:publisher] @published_at = options[:published_at] || Time.now super(PAYLOAD_TYPE, options) end
Public Instance Methods
==(other)
click to toggle source
Calls superclass method
# File lib/qs/event.rb, line 40 def ==(other) if other.kind_of?(self.class) self.payload_type == other.payload_type && self.channel == other.channel && self.name == other.name && self.params == other.params && self.publisher == other.publisher && self.published_at == other.published_at else super end end
inspect()
click to toggle source
# File lib/qs/event.rb, line 30 def inspect reference = '0x0%x' % (self.object_id << 1) "#<#{self.class}:#{reference} " \ "@channel=#{self.channel.inspect} " \ "@name=#{self.name.inspect} " \ "@params=#{self.params.inspect} " \ "@publisher=#{self.publisher.inspect} " \ "@published_at=#{self.published_at.inspect}>" end
route_name()
click to toggle source
# File lib/qs/event.rb, line 22 def route_name @route_name ||= Event::RouteName.new(self.channel, self.name) end
subscribers_redis_key()
click to toggle source
# File lib/qs/event.rb, line 26 def subscribers_redis_key @subscribers_redis_key ||= SubscribersRedisKey.new(self.route_name) end
Private Instance Methods
validate!(channel, name, params)
click to toggle source
# File lib/qs/event.rb, line 55 def validate!(channel, name, params) problem = if channel.to_s.empty? "The event doesn't have a channel." elsif name.to_s.empty? "The event doesn't have a name." elsif !params.kind_of?(::Hash) "The event's params are not valid." end raise(InvalidError, problem) if problem end