Module: ActiveDelivery::TestDelivery
- Included in:
- Base
- Defined in:
- lib/active_delivery/testing.rb
Class Method Summary collapse
- .clear ⇒ Object
- .enable ⇒ Object
- .enabled? ⇒ Boolean
- .store ⇒ Object
- .track(delivery, event, args, options) ⇒ Object
Instance Method Summary collapse
Class Method Details
.clear ⇒ Object
27 28 29 |
# File 'lib/active_delivery/testing.rb', line 27 def clear store.clear end |
.enable ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/active_delivery/testing.rb', line 4 def enable raise ArgumentError, "block is reauired" unless block_given? begin clear Thread.current[:active_delivery_testing] = true yield ensure Thread.current[:active_delivery_testing] = false end end |
.enabled? ⇒ Boolean
15 16 17 |
# File 'lib/active_delivery/testing.rb', line 15 def enabled? Thread.current[:active_delivery_testing] == true end |
.store ⇒ Object
23 24 25 |
# File 'lib/active_delivery/testing.rb', line 23 def store @store ||= [] end |
.track(delivery, event, args, options) ⇒ Object
19 20 21 |
# File 'lib/active_delivery/testing.rb', line 19 def track(delivery, event, args, ) store << [delivery, event, args, ] end |
Instance Method Details
#notify(event, *args, **options) ⇒ Object
32 33 34 35 36 |
# File 'lib/active_delivery/testing.rb', line 32 def notify(event, *args, **) return super unless test? TestDelivery.track(self, event, args, ) nil end |
#test? ⇒ Boolean
38 39 40 |
# File 'lib/active_delivery/testing.rb', line 38 def test? TestDelivery.enabled? end |