Class: Demux::SignalAttributes

Inherits:
Object
  • Object
show all
Defined in:
lib/demux/signal_attributes.rb

Overview

Attributes that are commonly used to identify a signal

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_id:, action:, object_id:, signal_class:) ⇒ SignalAttributes

Returns a new instance of SignalAttributes.


19
20
21
22
23
24
# File 'lib/demux/signal_attributes.rb', line 19

def initialize(account_id:, action:, object_id:, signal_class:)
  @account_id = 
  @action = action
  @object_id = object_id
  @signal_class = String(signal_class)
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id


6
7
8
# File 'lib/demux/signal_attributes.rb', line 6

def 
  @account_id
end

#actionObject (readonly)

Returns the value of attribute action


6
7
8
# File 'lib/demux/signal_attributes.rb', line 6

def action
  @action
end

#object_idObject (readonly)

Returns the value of attribute object_id


6
7
8
# File 'lib/demux/signal_attributes.rb', line 6

def object_id
  @object_id
end

#signal_classObject (readonly)

Returns the value of attribute signal_class


6
7
8
# File 'lib/demux/signal_attributes.rb', line 6

def signal_class
  @signal_class
end

Class Method Details

.from_object(object) ⇒ Object


9
10
11
12
13
14
15
16
# File 'lib/demux/signal_attributes.rb', line 9

def from_object(object)
  new(
    account_id: object.,
    action: object.action,
    object_id: object.object_id,
    signal_class: object.signal_class
  )
end

Instance Method Details

#hashedObject


35
36
37
38
39
40
41
42
# File 'lib/demux/signal_attributes.rb', line 35

def hashed
  Base64.strict_encode64({
    account_id: ,
    action: action,
    object_id: object_id,
    signal_class: signal_class
  }.to_json)
end

#to_hashObject


26
27
28
29
30
31
32
33
# File 'lib/demux/signal_attributes.rb', line 26

def to_hash
  {
    account_id: @account_id,
    action: @action,
    object_id: @object_id,
    signal_class: @signal_class
  }
end