lib/message_driver/adapters/base.rb in message-driver-0.2.1 vs lib/message_driver/adapters/base.rb in message-driver-0.2.2

- old
+ new

@@ -1,28 +1,33 @@ module MessageDriver module Adapters class Base include Logging - attr_accessor :contexts + def contexts + @contexts ||= [] + end def initialize(configuration) raise "Must be implemented in subclass" end def new_context - @contexts ||= [] ctx = build_context contexts << ctx ctx end def build_context raise "Must be implemented in subclass" end def stop - contexts.each { |ctx| ctx.invalidate } if contexts + if @contexts + ctxs = @contexts + @contexts = [] + ctxs.each { |ctx| ctx.invalidate } + end end end class ContextBase include Logging