Class: Appraisal::OrderedHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/appraisal/ordered_hash.rb

Overview

An ordered hash implementation for Ruby 1.8.7 compatibility. This is not a complete implementation, but it covers Appraisal's specific needs.

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ OrderedHash


7
8
9
10
# File 'lib/appraisal/ordered_hash.rb', line 7

def initialize(*args, &block)
  super
  @keys = []
end

Instance Method Details

#[]=(key, value) ⇒ Object


12
13
14
15
# File 'lib/appraisal/ordered_hash.rb', line 12

def []=(key, value)
  @keys << key unless has_key?(key)
  super
end

#valuesObject


17
18
19
# File 'lib/appraisal/ordered_hash.rb', line 17

def values
  @keys.collect { |key| self[key] }
end