Module: CommandTower::Messaging::Endpoints::ChannelGate

Defined in:
app/services/command_tower/messaging/endpoints/channel_gate.rb

Class Method Summary collapse

Class Method Details

.assert_endpoint_backed!(channel_key) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/command_tower/messaging/endpoints/channel_gate.rb', line 9

def assert_endpoint_backed!(channel_key)
  key = channel_key.to_s
  definition = Channels.fetch(key)
  if definition.nil?
    raise ValidationError, "unknown channel: #{key.inspect}"
  end
  unless definition.supports_endpoint_records
    raise ValidationError,
          "channel #{key.inspect} does not support endpoint records"
  end

  definition
end

.assert_record_supported!(record) ⇒ Object

Historical unsupported rows must not be exposed via show/mutate/verify.



24
25
26
27
28
29
30
31
# File 'app/services/command_tower/messaging/endpoints/channel_gate.rb', line 24

def assert_record_supported!(record)
  definition = Channels.fetch(record.channel_key)
  unless definition&.supports_endpoint_records
    raise NotFoundError, "endpoint not found"
  end

  definition
end

.supported_channel_keysObject



33
34
35
# File 'app/services/command_tower/messaging/endpoints/channel_gate.rb', line 33

def supported_channel_keys
  Channels.definitions.select(&:supports_endpoint_records).map(&:key).freeze
end