@@ -4,17 +4,22 @@ def needs_init?
44return false if Hyperloop . transport == :none
55return true if connection . respond_to? ( :data_sources ) && !connection . data_sources . include? ( table_name )
66return 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
1823end
1924
2025def create_table ( *args , &block )
0 commit comments