Skip to content

Commit 225b825

Browse files
committed
Avoid initializing the singleton unecessarily
1 parent 8f3c4fa commit 225b825

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/pusher.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,12 @@ def logger
4949
end
5050

5151
def default_client
52-
@default_client ||= Pusher::Client.new
52+
@default_client ||= begin
53+
cli = Pusher::Client
54+
ENV['PUSHER_URL'] ? cli.from_env : cli.new
55+
end
5356
end
5457
end
55-
56-
if ENV['PUSHER_URL']
57-
self.url = ENV['PUSHER_URL']
58-
end
5958
end
6059

6160
require 'pusher/channel'

0 commit comments

Comments
 (0)