123456789_123456789_123456789_123456789_123456789_

Module: Bundler::URI::Util

Do not use. This module is for internal use only.
Relationships & Source Files
Defined in: lib/bundler/vendor/uri/lib/uri/common.rb

Class Method Summary

Class Method Details

.make_components_hash(klass, array_hash) (mod_func)

[ GitHub ]

  
# File 'lib/bundler/vendor/uri/lib/uri/common.rb', line 33

def make_components_hash(klass, array_hash)
  tmp = {}
  if array_hash.kind_of?(Array) &&
      array_hash.size == klass.component.size - 1
    klass.component[1..-1].each_index do |i|
      begin
        tmp[klass.component[i + 1]] = array_hash[i].clone
      rescue TypeError
        tmp[klass.component[i + 1]] = array_hash[i]
      end
    end

  elsif array_hash.kind_of?(Hash)
    array_hash.each do |key, value|
      begin
        tmp[key] = value.clone
      rescue TypeError
        tmp[key] = value
      end
    end
  else
    raise ArgumentError,
      "expected Array of or Hash of components of #{klass} (#{klass.component[1..-1].join(', ')})"
  end
  tmp[:scheme] = klass.to_s.sub(/\A.*::/, '').downcase

  return tmp
end