Class: Asimov::Utils::RequestOptionsValidator
- Inherits:
-
Object
- Object
- Asimov::Utils::RequestOptionsValidator
- Defined in:
- lib/asimov/utils/request_options_validator.rb
Overview
Validates a set of request options that are passed to the application configuration or on Asimov::Client initialization. Ensures that the value is a hash, that all keys are symbols, and that all keys correspond to legitimate options (typically relating to network behavior). Currently does not validate the option values.
Constant Summary collapse
- ALLOWED_OPTIONS =
This is taken from HTTParty
%i[timeout open_timeout read_timeout write_timeout local_host local_port verify verify_peer ssl_ca_file ssl_ca_path ssl_version ciphers http_proxyaddr http_proxyport http_proxyuser http_proxypass].freeze
Class Method Summary collapse
- .supported_option?(key) ⇒ Boolean
-
.validate(options) ⇒ Object
Validates that the options are allowed request options.
Class Method Details
.supported_option?(key) ⇒ Boolean
56 57 58 |
# File 'lib/asimov/utils/request_options_validator.rb', line 56 def self.supported_option?(key) ALLOWED_OPTIONS.include?(key) end |
.validate(options) ⇒ Object
Validates that the options are allowed request options. Currently checks the keys - both that they are symbols and that they are allowed options. Does not validate values.
Only entry point for this class.
@param [Hash] options the set of request options to validate
27 28 29 30 31 32 33 34 35 |
# File 'lib/asimov/utils/request_options_validator.rb', line 27 def self.validate() unless .is_a?(Hash) raise Asimov::ConfigurationError, "Request options must be a hash" end (()) end |