Sha256: 5fa51ed6252501469d9c207f76a57344e887994f46f45ef1228cd9b4788565cf

Contents?: true

Size: 669 Bytes

Versions: 2

Compression:

Stored size: 669 Bytes

Contents

# coding: utf-8

module ThinReports
  module Core
    
    ruby_18 do
      # @private
      class OrderedHash < ::Hash
        def initialize
          @keys = []
          super
        end
        
        def []=(key, value)
          @keys << key unless member?(key)
          super
        end
        
        def each
          @keys.each {|key| yield(key, self[key])}
        end
        
        def each_key
          @keys.each {|key| yield(key)}
        end
        
        def keys
          @keys
        end
      end
    end
    
    ruby_19 do
      # @private
      OrderedHash = ::Hash
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thinreports-0.7.0 lib/thinreports/core/ordered_hash.rb
thinreports-0.6.0.pre3 lib/thinreports/core/ordered_hash.rb