Module: TelegramSupportBot::AdapterFactory

Defined in:
lib/telegram_support_bot/adapter_factory.rb

Constant Summary collapse

ADAPTERS =
{
  telegram_bot: 'TelegramSupportBot::Adapters::TelegramBot',
  telegram_bot_ruby: 'TelegramSupportBot::Adapters::TelegramBotRuby'
  # Add more predefined adapters here
}.freeze

Class Method Summary collapse

Class Method Details

.build(adapter_specification, adapter_options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/telegram_support_bot/adapter_factory.rb', line 10

def self.build(adapter_specification, adapter_options = {})
  case adapter_specification
  when Symbol
    adapter_class = ADAPTERS[adapter_specification].constantize
    adapter_class.new(adapter_options)
  when Class
    adapter_specification.new(adapter_options)
  else
    raise ArgumentError, "Unsupported adapter specification: #{adapter_specification}"
  end
end