Class: Coruro
- Inherits:
-
Object
- Object
- Coruro
- Extended by:
- Forwardable
- Defined in:
- lib/coruro.rb,
lib/coruro/message.rb,
lib/coruro/version.rb,
lib/coruro/mailcatcher_adapter.rb
Defined Under Namespace
Classes: MailcatcherAdapter, Message, UnrecognizedAdapterError
Constant Summary collapse
- VERSION =
"0.6.0"
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
Class Method Summary collapse
Instance Method Summary collapse
- #adapters ⇒ Object
-
#initialize(adapter:, on_wait_tick: -> (count) { }, timeout: 1.0, adapter_config: {}) ⇒ Coruro
constructor
A new instance of Coruro.
- #wait_until_up(on_tick) ⇒ Object
Constructor Details
#initialize(adapter:, on_wait_tick: -> (count) { }, timeout: 1.0, adapter_config: {}) ⇒ Coruro
Returns a new instance of Coruro.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/coruro.rb', line 14 def initialize(adapter:, on_wait_tick: -> (count) { }, timeout: 1.0, adapter_config: {}) if adapters.key?(adapter) self.adapter = adapters[adapter].new(timeout: timeout, config: adapter_config) self.adapter.start unless self.adapter.up? else raise UnrecognizedAdapterError, adapter end wait_until_up(on_wait_tick) end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
10 11 12 |
# File 'lib/coruro.rb', line 10 def adapter @adapter end |
Class Method Details
.adapters ⇒ Object
41 42 43 |
# File 'lib/coruro.rb', line 41 def self.adapters @adapters ||= { mailcatcher: MailcatcherAdapter } end |
Instance Method Details
#adapters ⇒ Object
37 38 39 |
# File 'lib/coruro.rb', line 37 def adapters self.class.adapters end |
#wait_until_up(on_tick) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/coruro.rb', line 25 def wait_until_up(on_tick) count = 0 until adapter.up? || count > 5 on_tick.call(count) sleep(1) count = count + 1 end end |