Sha256: 98b41fa6e21b60e2bedb1b4f2eb30d432d179990382404ddfbd283c9e4274f06
Contents?: true
Size: 895 Bytes
Versions: 9
Compression:
Stored size: 895 Bytes
Contents
# Helper for validating required options module OptionsHelper # Validates a list of options against a list of required options # @param [Array] options list of options to validate # @param [Array] required list of required options # @param [Array] valid list of additional valid options # @return true # @raise [ArgumentError] if the options do not pass validation # @api private def validate_options(options, required = [], valid = []) options = {} if options.nil? required = {} if required.nil? # make sure all the required options exist required.each do |k| raise ArgumentError.new("Missing required parameter: #{k}") unless options.has_key?(k) end # make sure no invalid options exist options.each do |k, v| raise ArgumentError.new("Invalid parameter: #{k}") unless required.include?(k) || valid.include?(k) end true end end
Version data entries
9 entries across 9 versions & 1 rubygems