Class: Pubsubstub::Event
- Inherits:
-
Object
- Object
- Pubsubstub::Event
- Defined in:
- lib/pubsubstub/event.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#retry_after ⇒ Object
readonly
Returns the value of attribute retry_after.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(data, options = {}) ⇒ Event
constructor
A new instance of Event.
- #to_json ⇒ Object
- #to_message ⇒ Object
Constructor Details
#initialize(data, options = {}) ⇒ Event
Returns a new instance of Event.
5 6 7 8 9 10 |
# File 'lib/pubsubstub/event.rb', line 5 def initialize(data, = {}) @id = [:id] || time_now @name = [:name] @retry_after = [:retry_after] @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/pubsubstub/event.rb', line 3 def data @data end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/pubsubstub/event.rb', line 3 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/pubsubstub/event.rb', line 3 def name @name end |
#retry_after ⇒ Object (readonly)
Returns the value of attribute retry_after.
3 4 5 |
# File 'lib/pubsubstub/event.rb', line 3 def retry_after @retry_after end |
Class Method Details
.from_json(json) ⇒ Object
20 21 22 23 |
# File 'lib/pubsubstub/event.rb', line 20 def self.from_json(json) hash = JSON.load(json) new(hash['data'], name: hash['name'], id: hash['id'], retry_after: hash['retry_after']) end |
Instance Method Details
#==(other) ⇒ Object
25 26 27 |
# File 'lib/pubsubstub/event.rb', line 25 def ==(other) id == other.id && name == other.name && data == other.data && retry_after == other.retry_after end |
#to_json ⇒ Object
12 13 14 |
# File 'lib/pubsubstub/event.rb', line 12 def to_json {id: @id, name: @name, data: @data, retry_after: @retry_after}.to_json end |
#to_message ⇒ Object
16 17 18 |
# File 'lib/pubsubstub/event.rb', line 16 def @message ||= end |