Class: Parabot::Messaging::AdapterFactory
- Inherits:
-
Object
- Object
- Parabot::Messaging::AdapterFactory
- 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
-
.available_types ⇒ Array<Symbol>
List of available adapter types.
-
.create(type = :tmux, **kwargs) ⇒ Messaging::Adapter
An instance of the requested adapter.
Class Method Details
.available_types ⇒ Array<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.
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 |