class Routemaster::Client::Configuration
Constants
- DEFAULT_LAZY
- DEFAULT_TIMEOUT
- DEFAULT_VERIFY_SSL
Attributes
async_backend[RW]
lazy[RW]
timeout[RW]
url[RW]
uuid[RW]
verify_ssl[RW]
Public Class Methods
configure() { |self| ... }
click to toggle source
# File routemaster/client/configuration.rb, line 17 def configure yield self _validate_all_options! end
reset()
click to toggle source
# File routemaster/client/configuration.rb, line 22 def reset %w[url uuid timeout async_backend lazy verify_ssl].each do |ivar| remove_instance_variable :"@#{ivar}" if instance_variable_defined? :"@#{ivar}" end end
Private Class Methods
_assert_boolean!(**kwargs)
click to toggle source
# File routemaster/client/configuration.rb, line 60 def _assert_boolean!(**kwargs) kwargs.each do |name, value| unless [true, false].include? value raise InvalidAttributeError, "#{name} '#{value}' is invalid, must be a boolean value: true or false" end end end
_assert_present!(**kwargs)
click to toggle source
# File routemaster/client/configuration.rb, line 68 def _assert_present!(**kwargs) kwargs.each do |name, value| raise MissingAttributeError, "#{name} is required" unless value end end
_assert_valid_timeout!(timeout)
click to toggle source
# File routemaster/client/configuration.rb, line 54 def _assert_valid_timeout!(timeout) unless (0..3_600_000).include? timeout raise InvalidAttributeError, "timeout '#{timeout}' is invalid, must be an integer between 0 and 3,600,000" end end
_assert_valid_url!(url)
click to toggle source
# File routemaster/client/configuration.rb, line 41 def _assert_valid_url!(url) assert_valid_url_throwing_error!(url, InvalidAttributeError) end
_assert_valid_uuid!(uuid)
click to toggle source
# File routemaster/client/configuration.rb, line 45 def _assert_valid_uuid!(uuid) raise MissingAttributeError, "uuid is required" unless uuid unless uuid =~ /^[a-z0-9_-]{1,64}$/ message = "uuid '#{uuid}' is invalid, must only contain alphanumeric characters " + "plus _ and - and be 1 to 64 characters" raise InvalidAttributeError, message end end
_validate_all_options!()
click to toggle source
# File routemaster/client/configuration.rb, line 30 def _validate_all_options! _assert_present! url: url, uuid: uuid _assert_valid_url!(url) _assert_valid_uuid!(uuid) timeout ? _assert_valid_timeout!(timeout) : self.timeout = DEFAULT_TIMEOUT lazy.nil? ? self.lazy = DEFAULT_LAZY : _assert_boolean!(lazy: lazy) verify_ssl.nil? ? self.verify_ssl = DEFAULT_VERIFY_SSL : _assert_boolean!(verify_ssl: verify_ssl) self.async_backend ||= Backends::MissingAsynchronous end