Sha256: 09a3fd70163d7867c518ab58a35c74c5bc65fd22efab7314a528bf822192aab8

Contents?: true

Size: 527 Bytes

Versions: 2

Compression:

Stored size: 527 Bytes

Contents

#
# auto vivifying ordered hash that dumps as yaml nicely
#
require 'orderedhash' unless defined? OrderedHash

class AutoOrderedHash < OrderedHash
  def initialize(*args)
    super(*args){|a,k| a[k] = __class__.new(*args)}
  end
  def class # for nice yaml
    Hash
  end
  def __class__
    AutoOrderedHash
  end
end # class AutoOrderedHash

OrderedAutoHash = AutoOrderedHash

def OrderedAutoHash(*a, &b)
  OrderedAutoHash.new(*a, &b)
end
def AutoOrderedHash(*a, &b)
  AutoOrderedHash.new(*a, &b)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ThiagoLelis-backgroundjob-1.0.5 lib/orderedautohash.rb
ThiagoLelis-backgroundjob-1.0.6 lib/orderedautohash.rb