Sha256: e12be7dc1b748bbd03b5effaa963c005b791973bf03c57c5be41311119bf3a53

Contents?: true

Size: 625 Bytes

Versions: 9

Compression:

Stored size: 625 Bytes

Contents

module RubyPsigate
  module Utils

    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) 

          valid_options = param[1..-1]
          raise ArgumentError.new("Parameter: #{param.first} must be one of #{valid_options.to_sentence(:words_connector => 'or')}") unless valid_options.include?(hash[param.first])
        else
          raise ArgumentError.new("Missing required parameter: #{param}") unless hash.has_key?(param) 
        end
      end
    end
    
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby_psigate-0.7.8 lib/ruby_psigate/utils.rb
ruby_psigate-0.7.7 lib/ruby_psigate/utils.rb
ruby_psigate-0.7.6 lib/ruby_psigate/utils.rb
ruby_psigate-0.7.5 lib/ruby_psigate/utils.rb
ruby_psigate-0.7.4 lib/ruby_psigate/utils.rb
ruby_psigate-0.7.3 lib/ruby_psigate/utils.rb
ruby_psigate-0.7.2 lib/ruby_psigate/utils.rb
ruby_psigate-0.7.1 lib/ruby_psigate/utils.rb
ruby_psigate-0.7 lib/ruby_psigate/utils.rb