Module: Outbox::MessageClients::ClassMethods
- Defined in:
- lib/outbox/message_clients.rb
Instance Method Summary collapse
-
#default_client(client = nil, options = nil) ⇒ Object
Returns the default client for the message type.
-
#register_client_alias(name, client) ⇒ Object
Registers a client class with an alias.
-
#registered_client_aliases ⇒ Object
Returns a hash of client aliases, where the key is the alias and the value is client class.
Instance Method Details
#default_client(client = nil, options = nil) ⇒ Object
Returns the default client for the message type.
Email.default_client #=> #<Outbox::Clients::Mail>
Also allows you to set the default client using an alias, with optoins.
Email.default_client :test, option: 'foo'
Email.default_client #=> #<Outbox::Clients::TestClient>
16 17 18 19 20 21 22 |
# File 'lib/outbox/message_clients.rb', line 16 def default_client(client = nil, = nil) if client.nil? @default_client else @default_client = get_client(client, ) end end |
#register_client_alias(name, client) ⇒ Object
Registers a client class with an alias.
Email.register_client_alias :mandrill, MandrillClient
Email.default_client :mandrill, mandrill_option: 'foo'
28 29 30 |
# File 'lib/outbox/message_clients.rb', line 28 def register_client_alias(name, client) registered_client_aliases[name.to_sym] = client end |
#registered_client_aliases ⇒ Object
Returns a hash of client aliases, where the key is the alias and the value is client class.
34 35 36 |
# File 'lib/outbox/message_clients.rb', line 34 def registered_client_aliases @registered_client_aliases ||= { test: Outbox::Clients::TestClient } end |