Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit a99ab14

Browse files
committed
closes (hopefully) #21
1 parent 1b9445a commit a99ab14

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

Diff for: lib/hyper-operation/transport/connection.rb

+16-11
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@ def needs_init?
44
return false if Hyperloop.transport == :none
55
return true if connection.respond_to?(:data_sources) && !connection.data_sources.include?(table_name)
66
return true if !connection.respond_to?(:data_sources) && !connection.tables.include?(table_name)
7-
return false unless Hyperloop.on_server?
8-
return true if defined?(Rails::Server)
9-
return true unless Connection.root_path
10-
uri = URI("#{Connection.root_path}server_up")
11-
http = Net::HTTP.new(uri.host, uri.port)
12-
request = Net::HTTP::Get.new(uri.path)
13-
if uri.scheme == 'https'
14-
http.use_ssl = true
15-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
16-
end
17-
http.request(request) && return rescue true
7+
Hyperloop.on_server?
8+
# the above line appears equivilent to the following two original lines
9+
# the only
10+
# return false unless Hyperloop.on_server?
11+
# return true if defined?(Rails::Server)
12+
# the following lines appeared to be unreachable but perhaps because on_server uses Rails.const_defined? it has some
13+
# subtle difference.
14+
# return true unless Connection.root_path
15+
# uri = URI("#{Connection.root_path}server_up")
16+
# http = Net::HTTP.new(uri.host, uri.port)
17+
# request = Net::HTTP::Get.new(uri.path)
18+
# if uri.scheme == 'https'
19+
# http.use_ssl = true
20+
# http.verify_mode = OpenSSL::SSL::VERIFY_NONE
21+
# end
22+
# http.request(request) && return rescue true
1823
end
1924

2025
def create_table(*args, &block)

Diff for: lib/hyper-operation/transport/hyperloop.rb

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def self.send_data(channel, data)
122122
end
123123

124124
def self.on_server?
125+
return !Rails.const_defined?('Console')
125126
if !Rails.const_defined?('Console') || Rails.const_defined?('Puma') || Rails.const_defined?('Unicorn') || Rails.const_defined?('Server')
126127
true
127128
elsif Rails.const_defined?('Console')

0 commit comments

Comments
 (0)