Class: ActiveWarehouse::OrderedHash

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

Overview

Simple ordered hash implementation

Instance Method Summary collapse

Constructor Details

#initializeOrderedHash

Returns a new instance of OrderedHash.



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

def initialize
  @keys = []
end

Instance Method Details

#[]=(key, val) ⇒ Object



11
12
13
14
# File 'lib/active_warehouse/ordered_hash.rb', line 11

def []=(key, val)
  @keys << key
  super
end

#delete(key) ⇒ Object



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

def delete(key)
  @keys.delete(key)
  super
end

#eachObject



21
22
23
# File 'lib/active_warehouse/ordered_hash.rb', line 21

def each
  @keys.each { |k| yield k, self[k] }
end

#each_keyObject



25
26
27
# File 'lib/active_warehouse/ordered_hash.rb', line 25

def each_key
  @keys.each { |k| yield k }
end

#each_pairObject



5
# File 'lib/active_warehouse/ordered_hash.rb', line 5

alias_method :each_pair, :each

#each_valueObject



29
30
31
# File 'lib/active_warehouse/ordered_hash.rb', line 29

def each_value
  @keys.each { |k| yield self[k] }
end

#storeObject



4
# File 'lib/active_warehouse/ordered_hash.rb', line 4

alias_method :store, :[]=