class DerailSpecs::InitializerHooks

Public Class Methods

instance() click to toggle source
# File lib/derail_specs/initializer_hooks.rb, line 7
def self.instance
  @instance ||= new
end
new() click to toggle source
# File lib/derail_specs/initializer_hooks.rb, line 36
def initialize
  reset!
end

Public Instance Methods

before_server_start(&blk) click to toggle source
# File lib/derail_specs/initializer_hooks.rb, line 11
def before_server_start(&blk)
  register(:before_server_start, blk)
end
before_server_stop(&blk) click to toggle source
# File lib/derail_specs/initializer_hooks.rb, line 15
def before_server_stop(&blk)
  register(:before_server_stop, blk)
end
reset!() click to toggle source
# File lib/derail_specs/initializer_hooks.rb, line 19
def reset!
  @hooks = {}
end
run(name) click to toggle source
# File lib/derail_specs/initializer_hooks.rb, line 23
def run(name)
  return unless @hooks[name]

  @hooks[name].each(&:call)
end

Private Instance Methods

register(name, blk) click to toggle source
# File lib/derail_specs/initializer_hooks.rb, line 31
def register(name, blk)
  @hooks[name] ||= []
  @hooks[name] << blk
end