Sha256: 972f88e38a1ab060e3442853b4eb69599a2304ada796e97fee3474055232b1be

Contents?: true

Size: 1017 Bytes

Versions: 19

Compression:

Stored size: 1017 Bytes

Contents

class Hash
  # Standard in Ruby 1.8.8. See official documentation[http://ruby-doc.org/core-1.9/classes/Hash.html]
  class << self
    def try_convert(x)
      Backports.try_convert(x, Hash, :to_hash)
    end unless method_defined? :try_convert
  end

  # Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Hash.html]
  def default_proc=(proc)
    replace(Hash.new(&Backports.coerce_to(proc, Proc, :to_proc)).merge!(self))
  end unless method_defined? :default_proc=

  # Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Hash.html]
  def assoc(key)
    val = fetch(key) do
      return find do |k, v|
        [k, v] if k == key
      end
    end
    [key, val]
  end unless method_defined? :assoc


  # Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Hash.html]
  def rassoc(value)
    k = key(value)
    v = fetch(k){return nil}
    [k, fetch(k)] if k || v == value
  end unless method_defined? :rassoc
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
backports-2.8.2 lib/backports/1.9.1/hash.rb
backports-2.8.1 lib/backports/1.9.1/hash.rb
backports-2.8.0 lib/backports/1.9.1/hash.rb
backports-2.7.1 lib/backports/1.9.1/hash.rb
backports-2.7.0 lib/backports/1.9.1/hash.rb
backports-2.6.7 lib/backports/1.9.1/hash.rb
backports-2.6.6 lib/backports/1.9.1/hash.rb
backports-2.6.5 lib/backports/1.9.1/hash.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/backports-2.6.4/lib/backports/1.9.1/hash.rb
backports-2.6.4 lib/backports/1.9.1/hash.rb
backports-2.6.3 lib/backports/1.9.1/hash.rb
backports-2.6.2 lib/backports/1.9.1/hash.rb
backports-2.6.1 lib/backports/1.9.1/hash.rb
backports-2.6.0 lib/backports/1.9.1/hash.rb
backports-2.5.3 lib/backports/1.9.1/hash.rb
backports-2.5.2 lib/backports/1.9.1/hash.rb
backports-2.5.1 lib/backports/1.9.1/hash.rb
backports-2.5.0 lib/backports/1.9.1/hash.rb
backports-2.4.0 lib/backports/1.9.1/hash.rb