Sha256: f12db4be7ca09da5d72339ddad8238d8b81b5d4255dd17e04a41f088db1831cb

Contents?: true

Size: 974 Bytes

Versions: 15

Compression:

Stored size: 974 Bytes

Contents

class Hash # :nodoc:

  def except(*items) # :nodoc:
    puts "array except works!!!"
    self.dup.except!(*items)
  end unless method_defined?(:except)

  def except!(*keys) # :nodoc:
    copy = self.dup
    keys.each { |key| copy.delete!(key) }
    copy
  end unless method_defined?(:except!)

  def symbolize_keys  # :nodoc:
    inject({}) do |hash, (key, value)|
      hash[(key.to_sym rescue key) || key] = value
      hash
    end
  end

  def symbolize_keys! # :nodoc:
    hash = symbolize_keys
    hash.each do |key, val|
      hash[key] = case val
        when Hash
          val.symbolize_keys!
        when Array
          val.map do |item|
            item.is_a?(Hash) ? item.symbolize_keys! : item
          end
        else
          val
        end
    end
    return hash
  end unless method_defined?(:symbolize_keys!)

  def serialize # :nodoc:
    self.map { |key, val| [key, val].join("=") }.join("&")
  end unless method_defined?(:serialize)

end # Hash

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
github_api-0.4.2 lib/github_api/core_ext/hash.rb
github_api-0.4.1 lib/github_api/core_ext/hash.rb
github_api-0.4.0 lib/github_api/core_ext/hash.rb
github_api-0.3.9 lib/github_api/core_ext/hash.rb
github_api-0.3.8 lib/github_api/core_ext/hash.rb
github_api-0.3.7 lib/github_api/core_ext/hash.rb
github_api-0.3.6 lib/github_api/core_ext/hash.rb
github_api-0.3.4 lib/github_api/core_ext/hash.rb
github_api-0.3.3 lib/github_api/core_ext/hash.rb
github_api-0.3.2 lib/github_api/core_ext/hash.rb
github_api-0.3.1 lib/github_api/core_ext/hash.rb
github_api-0.3.0 lib/github_api/core_ext/hash.rb
github_api-0.2.2 lib/github_api/core_ext/hash.rb
github_api-0.2.1 lib/github_api/core_ext/hash.rb
github_api-0.2.0 lib/github_api/core_ext/hash.rb