10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/services/jumbotron/services/adapters/resolve_discovery.rb', line 10
def call
Jumbotron::Adapters::Registry.ensure_loaded!
adapter = Jumbotron::Adapters::Registry.find(adapter_id)
if adapter.nil?
context.fail!(
application_error: Jumbotron::Errors::Adapters::UnknownAdapterError.new(
details: { adapter_id: adapter_id }
)
)
return
end
unless adapter.registered?
context.fail!(
application_error: Jumbotron::Errors::Adapters::NotRegisteredError.new(
details: { adapter: adapter.to_s }
)
)
return
end
definition = lookup_discovery(adapter)
return if definition.nil?
context.adapter = adapter
context.definition = definition
end
|