Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hooks for on_booted event. #1160

Merged
merged 2 commits into from Nov 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions lib/puma/events.rb
Expand Up @@ -34,8 +34,6 @@ def initialize(stdout, stderr)

@debug = ENV.key? 'PUMA_DEBUG'

@on_booted = []

@hooks = Hash.new { |h,k| h[k] = [] }
end

Expand All @@ -48,7 +46,7 @@ def fire(hook, *args)
@hooks[hook].each { |t| t.call(*args) }
end

# Register a callbock for a given hook
# Register a callback for a given hook
#
def register(hook, obj=nil, &blk)
if obj and blk
Expand Down Expand Up @@ -124,12 +122,12 @@ def unknown_error(server, error, kind="Unknown", env=nil)
end
end

def on_booted(&b)
@on_booted << b
def on_booted(&block)
register(:on_booted, &block)
end

def fire_on_booted!
@on_booted.each { |b| b.call }
fire(:on_booted)
end

DEFAULT = new(STDOUT, STDERR)
Expand Down