Class: Twingly::AMQP::PingOptions
- Inherits:
-
Object
- Object
- Twingly::AMQP::PingOptions
- Defined in:
- lib/twingly/amqp/ping_options.rb
Instance Attribute Summary collapse
-
#custom_options ⇒ Object
Returns the value of attribute custom_options.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#provider_name ⇒ Object
Returns the value of attribute provider_name.
-
#source_ip ⇒ Object
Returns the value of attribute source_ip.
Instance Method Summary collapse
-
#initialize(provider_name: nil, source_ip: nil, priority: nil, custom_options: {}) {|_self| ... } ⇒ PingOptions
constructor
A new instance of PingOptions.
- #merge(other) ⇒ Object
- #to_h ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(provider_name: nil, source_ip: nil, priority: nil, custom_options: {}) {|_self| ... } ⇒ PingOptions
Returns a new instance of PingOptions.
8 9 10 11 12 13 14 15 16 |
# File 'lib/twingly/amqp/ping_options.rb', line 8 def initialize(provider_name: nil, source_ip: nil, priority: nil, custom_options: {}) self.provider_name = provider_name self.source_ip = source_ip self.priority = priority self. = yield self if block_given? end |
Instance Attribute Details
#custom_options ⇒ Object
Returns the value of attribute custom_options.
6 7 8 |
# File 'lib/twingly/amqp/ping_options.rb', line 6 def @custom_options end |
#priority ⇒ Object
Returns the value of attribute priority.
4 5 6 |
# File 'lib/twingly/amqp/ping_options.rb', line 4 def priority @priority end |
#provider_name ⇒ Object
Returns the value of attribute provider_name.
4 5 6 |
# File 'lib/twingly/amqp/ping_options.rb', line 4 def provider_name @provider_name end |
#source_ip ⇒ Object
Returns the value of attribute source_ip.
4 5 6 |
# File 'lib/twingly/amqp/ping_options.rb', line 4 def source_ip @source_ip end |
Instance Method Details
#merge(other) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/twingly/amqp/ping_options.rb', line 45 def merge(other) PingOptions.new do || .provider_name = other.provider_name || provider_name .source_ip = other.source_ip || source_ip .priority = other.priority || priority . = .merge(other.) end end |
#to_h ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/twingly/amqp/ping_options.rb', line 26 def to_h { provider_name: provider_name, source_ip: source_ip, priority: priority, custom_options: , } end |
#validate ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/twingly/amqp/ping_options.rb', line 35 def validate missing_keys = to_h.select do |key, value| key != :custom_options && value.to_s.empty? end.keys if missing_keys.any? raise ArgumentError, "Required options not set: #{missing_keys}" end end |