Sha256: c21da07891ea33911bd8b222f378248b6829aeb9dd18d88ce73c3f171d6fc033
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true module AnyCable module BroadcastAdapters # :nodoc: module_function # rubocop: disable Metrics/AbcSize, Metrics/MethodLength def lookup_adapter(args) adapter, options = Array(args) path_to_adapter = "anycable/broadcast_adapters/#{adapter}" adapter_class_name = adapter.to_s.split("_").map(&:capitalize).join unless BroadcastAdapters.const_defined?(adapter_class_name, false) begin require path_to_adapter rescue LoadError => e # We couldn't require the adapter itself. if e.path == path_to_adapter raise e.class, "Couldn't load the '#{adapter}' broadcast adapter for AnyCable", e.backtrace # Bubbled up from the adapter require. else raise e.class, "Error loading the '#{adapter}' broadcast adapter for AnyCable", e.backtrace end end end BroadcastAdapters.const_get(adapter_class_name, false).new(**(options || {})) end # rubocop: enable Metrics/AbcSize, Metrics/MethodLength end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
anycable-1.0.0.preview2 | lib/anycable/broadcast_adapters.rb |
anycable-1.0.0.preview1 | lib/anycable/broadcast_adapters.rb |