Class: Aikido::Zen::OutboundConnection
- Inherits:
-
Object
- Object
- Aikido::Zen::OutboundConnection
- Defined in:
- lib/aikido/zen/outbound_connection.rb
Overview
Simple data object to identify connections performed to outbound servers.
Instance Attribute Summary collapse
-
#host ⇒ String
readonly
The hostname or IP address to which the connection was attempted.
-
#port ⇒ Integer
readonly
The port number to which the connection was attempted.
Class Method Summary collapse
-
.from_uri(uri) ⇒ Aikido::Zen::OutboundConnection
Convenience factory to create connection descriptions out of URI objects.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #as_json ⇒ Object
- #hash ⇒ Object
-
#initialize(host:, port:) ⇒ OutboundConnection
constructor
A new instance of OutboundConnection.
- #inspect ⇒ Object
Constructor Details
#initialize(host:, port:) ⇒ OutboundConnection
Returns a new instance of OutboundConnection.
21 22 23 24 |
# File 'lib/aikido/zen/outbound_connection.rb', line 21 def initialize(host:, port:) @host = host @port = port end |
Instance Attribute Details
#host ⇒ String (readonly)
Returns the hostname or IP address to which the connection was attempted.
16 17 18 |
# File 'lib/aikido/zen/outbound_connection.rb', line 16 def host @host end |
#port ⇒ Integer (readonly)
Returns the port number to which the connection was attempted.
19 20 21 |
# File 'lib/aikido/zen/outbound_connection.rb', line 19 def port @port end |
Class Method Details
.from_uri(uri) ⇒ Aikido::Zen::OutboundConnection
Convenience factory to create connection descriptions out of URI objects.
10 11 12 |
# File 'lib/aikido/zen/outbound_connection.rb', line 10 def self.from_uri(uri) new(host: uri.hostname, port: uri.port) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
30 31 32 33 34 |
# File 'lib/aikido/zen/outbound_connection.rb', line 30 def ==(other) other.is_a?(OutboundConnection) && host == other.host && port == other.port end |
#as_json ⇒ Object
26 27 28 |
# File 'lib/aikido/zen/outbound_connection.rb', line 26 def as_json {hostname: host, port: port} end |
#hash ⇒ Object
37 38 39 |
# File 'lib/aikido/zen/outbound_connection.rb', line 37 def hash [host, port].hash end |
#inspect ⇒ Object
41 42 43 |
# File 'lib/aikido/zen/outbound_connection.rb', line 41 def inspect "#<#{self.class.name} #{host}:#{port}>" end |