Module: RequiresParameters
- Included in:
- Epp::Server, EppErrorResponse
- Defined in:
- lib/require_parameters.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#requires!(hash, *params) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/require_parameters.rb', line 2 def requires!(hash, *params) params.each do |param| if param.is_a?(Array) raise ArgumentError.new("Missing required parameter: #{param.first}") unless hash.has_key?(param.first) = param[1..-1] raise ArgumentError.new("Parameter: #{param.first} must be one of #{.to_sentence(:connector => 'or')}") unless .include?(hash[param.first]) else raise ArgumentError.new("Missing required parameter: #{param}") unless hash.has_key?(param) end end end |