Class: CommandTower::Messaging::RecipientReadiness::RecipientResult

Inherits:
Data
  • Object
show all
Defined in:
app/services/command_tower/messaging/recipient_readiness/recipient_result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#channelsObject (readonly)

Returns the value of attribute channels

Returns:

  • (Object)

    the current value of channels



6
7
8
# File 'app/services/command_tower/messaging/recipient_readiness/recipient_result.rb', line 6

def channels
  @channels
end

#evaluated_atObject (readonly)

Returns the value of attribute evaluated_at

Returns:

  • (Object)

    the current value of evaluated_at



6
7
8
# File 'app/services/command_tower/messaging/recipient_readiness/recipient_result.rb', line 6

def evaluated_at
  @evaluated_at
end

#recipient_idObject (readonly)

Returns the value of attribute recipient_id

Returns:

  • (Object)

    the current value of recipient_id



6
7
8
# File 'app/services/command_tower/messaging/recipient_readiness/recipient_result.rb', line 6

def recipient_id
  @recipient_id
end

Class Method Details

.build(recipient_id:, channels:, evaluated_at: Time.current) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/command_tower/messaging/recipient_readiness/recipient_result.rb', line 11

def self.build(recipient_id:, channels:, evaluated_at: Time.current)
  frozen_channels =
    channels.to_h do |key, result|
      [key.to_s, result]
    end.freeze

  new(
    recipient_id:,
    channels: frozen_channels,
    evaluated_at:,
  ).freeze
end

Instance Method Details

#channel(key) ⇒ Object



24
25
26
# File 'app/services/command_tower/messaging/recipient_readiness/recipient_result.rb', line 24

def channel(key)
  channels[key.to_s]
end

#ready_channel_keysObject



28
29
30
# File 'app/services/command_tower/messaging/recipient_readiness/recipient_result.rb', line 28

def ready_channel_keys
  channels.select { |_key, result| result.ready }.keys.freeze
end

#recipient_ready_channel_keysObject



32
33
34
# File 'app/services/command_tower/messaging/recipient_readiness/recipient_result.rb', line 32

def recipient_ready_channel_keys
  channels.select { |_key, result| result.recipient_ready }.keys.freeze
end