Skip to content

Commit

Permalink
separate getting router to a method to override it in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tagomoris committed May 20, 2016
1 parent 0d2c5f7 commit b0712e0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/fluent/plugin_helper/event_emitter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ def event_emitter_used_actually?
@_event_emitter_used_actually
end

def event_emitter_router(label_name)
if label_name
Engine.root_agent.find_label(label_name).event_router
else
Engine.root_agent.event_router
end
end

def initialize
super
@_event_emitter_used_actually = false
Expand All @@ -50,13 +58,7 @@ def initialize

def configure(conf)
super

if label_name = conf['@label']
label = Engine.root_agent.find_label(label_name)
@router = label.event_router
elsif @router.nil?
@router = Engine.root_agent.event_router
end
@router = event_emitter_router(conf['@label'])
end

def after_shutdown
Expand Down

0 comments on commit b0712e0

Please sign in to comment.