Class: ActiveWarehouse::OrderedHash
- Inherits:
-
Hash
- Object
- Hash
- ActiveWarehouse::OrderedHash
- Defined in:
- lib/active_warehouse/ordered_hash.rb
Overview
Simple ordered hash implementation
Instance Method Summary collapse
- #[]=(key, val) ⇒ Object
- #delete(key) ⇒ Object
- #each ⇒ Object
- #each_key ⇒ Object
- #each_pair ⇒ Object
- #each_value ⇒ Object
-
#initialize ⇒ OrderedHash
constructor
A new instance of OrderedHash.
- #store ⇒ Object
Constructor Details
#initialize ⇒ OrderedHash
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 |
#each ⇒ Object
21 22 23 |
# File 'lib/active_warehouse/ordered_hash.rb', line 21 def each @keys.each { |k| yield k, self[k] } end |
#each_key ⇒ Object
25 26 27 |
# File 'lib/active_warehouse/ordered_hash.rb', line 25 def each_key @keys.each { |k| yield k } end |
#each_pair ⇒ Object
5 |
# File 'lib/active_warehouse/ordered_hash.rb', line 5 alias_method :each_pair, :each |
#each_value ⇒ Object
29 30 31 |
# File 'lib/active_warehouse/ordered_hash.rb', line 29 def each_value @keys.each { |k| yield self[k] } end |
#store ⇒ Object
4 |
# File 'lib/active_warehouse/ordered_hash.rb', line 4 alias_method :store, :[]= |