Class: Akasha::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/akasha/event.rb

Overview

Describes a single event recorded by the system.

Direct Known Subclasses

RecordedEvent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, id = nil, metadata = {}, **data) ⇒ Event

Returns a new instance of Event.



9
10
11
12
13
14
# File 'lib/akasha/event.rb', line 9

def initialize(name, id = nil,  = {}, **data)
  @id = id || SecureRandom.uuid.to_s # TODO: Use something better.
  @name = name
  @metadata =  || { created_at: Time.now.utc }
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/akasha/event.rb', line 7

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/akasha/event.rb', line 7

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



7
8
9
# File 'lib/akasha/event.rb', line 7

def 
  @metadata
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/akasha/event.rb', line 7

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/akasha/event.rb', line 16

def ==(other)
  self.class == other.class &&
    id == other.id &&
    name == other.name &&
    data == other.data &&
     == other.
end

#with_metadata(metadata) ⇒ Object



24
25
26
# File 'lib/akasha/event.rb', line 24

def ()
  Event.new(@name, @id, @metadata.merge(), **@data)
end