Class: Parabot::Messaging::AdapterFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/parabot/messaging/adapter_factory.rb

Overview

Factory class to create appropriate messaging adapters

Constant Summary collapse

ADAPTERS =

Available adapter types

{
  tmux: TmuxAdapter,
  dry_run: DryRunAdapter
}.freeze

Class Method Summary collapse

Class Method Details

.available_typesArray<Symbol>



28
29
30
# File 'lib/parabot/messaging/adapter_factory.rb', line 28

def self.available_types
  ADAPTERS.keys
end

.create(type = :tmux, **kwargs) ⇒ Messaging::Adapter

Returns an instance of the requested adapter.

Raises:

  • (ArgumentError)

    if adapter type is not supported



20
21
22
23
24
25
# File 'lib/parabot/messaging/adapter_factory.rb', line 20

def self.create(type = :tmux, **kwargs)
  adapter_class = ADAPTERS[type]
  raise ArgumentError, "Unsupported adapter type: #{type}. Available types: #{ADAPTERS.keys}" unless adapter_class

  adapter_class.new(**kwargs)
end