From 0a18220df46e44d6d2000dfcfd18bf33a8f1d20a Mon Sep 17 00:00:00 2001 From: Alexey Nikitin Date: Fri, 6 Sep 2013 18:06:56 +0400 Subject: [PATCH] Inject params into PushDaemon --- lib/push_daemon.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/push_daemon.rb b/lib/push_daemon.rb index 87deda5..1946c11 100644 --- a/lib/push_daemon.rb +++ b/lib/push_daemon.rb @@ -19,9 +19,10 @@ require "push_notification" class PushDaemon - def initialize - @worker = Worker.new - @server = UDPServer.new(self) + def initialize(params = {}) + params = defaults.merge(params) + @worker = params[:worker] + @server = params[:server_class].new(self) end def start @@ -35,4 +36,13 @@ def call(client, message) job >> @worker end + + private + + def defaults + { + worker: Worker.new, + server_class: UDPServer + } + end end