Class: EventSource::Event

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



6
7
8
# File 'lib/event_source/event.rb', line 6

def created_at
  @created_at
end

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/event_source/event.rb', line 6

def data
  @data
end

#entity_idObject (readonly)

Returns the value of attribute entity_id.



6
7
8
# File 'lib/event_source/event.rb', line 6

def entity_id
  @entity_id
end

#entity_typeObject (readonly)

Returns the value of attribute entity_type.



6
7
8
# File 'lib/event_source/event.rb', line 6

def entity_type
  @entity_type
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/event_source/event.rb', line 6

def name
  @name
end

Class Method Details

.build_from_data(data) ⇒ Object



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

def build_from_data(data)
    event = self.new
    event.send(:new_from_data, data)
    event
end

.create(name, entity, args) ⇒ Object



15
16
17
18
19
# File 'lib/event_source/event.rb', line 15

def create(name, entity, args)
    event = self.new
    event.send(:new_from_entity, name, entity, args)
    event
end

Instance Method Details

#get_argsObject



22
23
24
# File 'lib/event_source/event.rb', line 22

def get_args
    JSON.parse(data)
end

#saveObject



26
27
28
29
# File 'lib/event_source/event.rb', line 26

def save
    raise CannotSaveRebuiltEvent if @is_rebuilt
    EventSource::EventRepository.current.save(self)
end