Sha256: d6f397cfdb0591a23c803a529cd42cbe19c15e103da64ee045073bf248dbc3b5
Contents?: true
Size: 1.89 KB
Versions: 8
Compression:
Stored size: 1.89 KB
Contents
module MultiMail # Interacts with email APIs to send or receive email. # # @see http://rdoc.info/gems/fog/Fog/Service module Service # Appends the given arguments to the list of required arguments. # # @param args one or more required arguments # @see Fog::Service::requires def requires(*args) requirements.concat(args) end # Returns the list of required arguments. # # @return [Array] a list of required arguments # @see Fog::Service::requirements def requirements @requirements ||= [] end # Appends the given arguments to the list of optional arguments. # # @param args one or more optional arguments # @see Fog::Service::recognizes def recognizes(*args) recognized.concat(args) end # Returns the list of optional arguments. # # @return [Array] a list of optional arguments # @see Fog::Service::recognized def recognized @recognized ||= [] end # Ensures that required arguments are present and that optional arguments # are recognized. # # @param [Hash] options arguments # @raise [ArgumentError] if it can't find a required argument or can't # recognize an optional argument # @see Fog::Service::validate_options def validate_options(options, raise_error_if_unrecognized = true) keys = [] for key, value in options unless value.nil? keys << key end end missing = requirements - keys unless missing.empty? raise ArgumentError, "Missing required arguments: #{missing.map(&:to_s).sort.join(', ')}" end if !recognizes.empty? && raise_error_if_unrecognized unrecognized = options.keys - requirements - recognized unless unrecognized.empty? raise ArgumentError, "Unrecognized arguments: #{unrecognized.map(&:to_s).sort.join(', ')}" end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems