Class: Event
- Inherits:
-
Struct
- Object
- Struct
- Event
- Defined in:
- lib/http_eventstore/event.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#event_id ⇒ Object
Returns the value of attribute event_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#position ⇒ Object
Returns the value of attribute position.
-
#stream_name ⇒ Object
Returns the value of attribute stream_name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, data, event_id = nil, id = nil, position = nil, stream_name = nil) ⇒ Event
constructor
A new instance of Event.
- #to_json(options) ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(type, data, event_id = nil, id = nil, position = nil, stream_name = nil) ⇒ Event
Returns a new instance of Event.
4 5 6 7 |
# File 'lib/http_eventstore/event.rb', line 4 def initialize(type, data, event_id=nil, id=nil, position=nil, stream_name=nil) event_id = SecureRandom.uuid if event_id.nil? super end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data
3 4 5 |
# File 'lib/http_eventstore/event.rb', line 3 def data @data end |
#event_id ⇒ Object
Returns the value of attribute event_id
3 4 5 |
# File 'lib/http_eventstore/event.rb', line 3 def event_id @event_id end |
#id ⇒ Object
Returns the value of attribute id
3 4 5 |
# File 'lib/http_eventstore/event.rb', line 3 def id @id end |
#position ⇒ Object
Returns the value of attribute position
3 4 5 |
# File 'lib/http_eventstore/event.rb', line 3 def position @position end |
#stream_name ⇒ Object
Returns the value of attribute stream_name
3 4 5 |
# File 'lib/http_eventstore/event.rb', line 3 def stream_name @stream_name end |
#type ⇒ Object
Returns the value of attribute type
3 4 5 |
# File 'lib/http_eventstore/event.rb', line 3 def type @type end |
Instance Method Details
#to_json(options) ⇒ Object
13 14 15 |
# File 'lib/http_eventstore/event.rb', line 13 def to_json() self.to_h.to_json end |
#validate ⇒ Object
9 10 11 |
# File 'lib/http_eventstore/event.rb', line 9 def validate [self.event_id, self.type, self.data].any? { |var| var.nil? || var.empty? } end |