Class: Igniter::Extensions::Contracts::Reactive::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/igniter/extensions/contracts/reactive/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_id:, type:, path:, status:, payload: {}) ⇒ Event

Returns a new instance of Event.



10
11
12
13
14
15
16
17
# File 'lib/igniter/extensions/contracts/reactive/event.rb', line 10

def initialize(event_id:, type:, path:, status:, payload: {})
  @event_id = event_id.to_s
  @type = type.to_sym
  @path = path&.to_sym
  @status = status.to_sym
  @payload = payload.freeze
  freeze
end

Instance Attribute Details

#event_idObject (readonly)

Returns the value of attribute event_id.



8
9
10
# File 'lib/igniter/extensions/contracts/reactive/event.rb', line 8

def event_id
  @event_id
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/igniter/extensions/contracts/reactive/event.rb', line 8

def path
  @path
end

#payloadObject (readonly)

Returns the value of attribute payload.



8
9
10
# File 'lib/igniter/extensions/contracts/reactive/event.rb', line 8

def payload
  @payload
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/igniter/extensions/contracts/reactive/event.rb', line 8

def status
  @status
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/igniter/extensions/contracts/reactive/event.rb', line 8

def type
  @type
end

Instance Method Details

#to_hObject



23
24
25
26
27
28
29
30
31
# File 'lib/igniter/extensions/contracts/reactive/event.rb', line 23

def to_h
  {
    event_id: event_id,
    type: type,
    path: path,
    status: status,
    payload: payload
  }
end

#valueObject



19
20
21
# File 'lib/igniter/extensions/contracts/reactive/event.rb', line 19

def value
  payload[:value]
end