Class: Qs::Event
Defined Under Namespace
Modules: RouteName, SubscribersRedisKey
Constant Summary collapse
- PAYLOAD_TYPE =
'event'
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#published_at ⇒ Object
readonly
Returns the value of attribute published_at.
-
#publisher ⇒ Object
readonly
Returns the value of attribute publisher.
Attributes inherited from Message
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(channel, name, options = nil) ⇒ Event
constructor
A new instance of Event.
- #inspect ⇒ Object
- #route_name ⇒ Object
- #subscribers_redis_key ⇒ Object
Methods inherited from Message
Constructor Details
#initialize(channel, name, options = nil) ⇒ Event
Returns a new instance of Event.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/qs/event.rb', line 11 def initialize(channel, name, = nil) ||= {} [:params] ||= {} validate!(channel, name, [:params]) @channel = channel @name = name @publisher = [:publisher] @published_at = [:published_at] || Time.now super(PAYLOAD_TYPE, ) end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
9 10 11 |
# File 'lib/qs/event.rb', line 9 def channel @channel end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/qs/event.rb', line 9 def name @name end |
#published_at ⇒ Object (readonly)
Returns the value of attribute published_at.
9 10 11 |
# File 'lib/qs/event.rb', line 9 def published_at @published_at end |
#publisher ⇒ Object (readonly)
Returns the value of attribute publisher.
9 10 11 |
# File 'lib/qs/event.rb', line 9 def publisher @publisher end |
Instance Method Details
#==(other) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# 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 ⇒ Object
30 31 32 33 34 35 36 37 38 |
# 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 ⇒ Object
22 23 24 |
# File 'lib/qs/event.rb', line 22 def route_name @route_name ||= Event::RouteName.new(self.channel, self.name) end |
#subscribers_redis_key ⇒ Object
26 27 28 |
# File 'lib/qs/event.rb', line 26 def subscribers_redis_key @subscribers_redis_key ||= SubscribersRedisKey.new(self.route_name) end |