Class: Neo4j::Driver::Net::ServerAddress

Inherits:
Data
  • Object
show all
Defined in:
lib/neo4j/driver/net.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host

Returns:

  • (Object)

    the current value of host



9
10
11
# File 'lib/neo4j/driver/net.rb', line 9

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port

Returns:

  • (Object)

    the current value of port



9
10
11
# File 'lib/neo4j/driver/net.rb', line 9

def port
  @port
end

Class Method Details

.of(host, port) ⇒ Object



10
11
12
# File 'lib/neo4j/driver/net.rb', line 10

def self.of(host, port)
  new(host, port)
end

Instance Method Details

#to_sObject

"host:port" (IPv6 hosts bracketed) — matches Java's ServerAddress.toString and Routing::ServerAddress#to_s. Without this, the default Data inspect (#<data … host="h", port=N>) leaks anywhere a caller stringifies the address: a custom resolver returns Net::ServerAddress values and Bolt::Connection#split_addr does addr.to_s.rpartition(":"), which then split on the :: inside the class name and fed the tail to Integer() — the ArgumentError across the v4x4/v5x0 resolver routing tests.



23
24
25
# File 'lib/neo4j/driver/net.rb', line 23

def to_s
  host.include?(':') && !host.start_with?('[') ? "[#{host}]:#{port}" : "#{host}:#{port}"
end