Class: Darthjee::CoreExt::Hash::KeysSorter
- Defined in:
- lib/darthjee/core_ext/hash/keys_sorter.rb
Instance Method Summary collapse
-
#initialize(hash, recursive: true) ⇒ KeysSorter
constructor
A new instance of KeysSorter.
- #sort ⇒ Object
Constructor Details
#initialize(hash, recursive: true) ⇒ KeysSorter
Returns a new instance of KeysSorter.
7 8 9 10 |
# File 'lib/darthjee/core_ext/hash/keys_sorter.rb', line 7 def initialize(hash, recursive: true) @hash = hash @recursive = recursive end |
Instance Method Details
#sort ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/darthjee/core_ext/hash/keys_sorter.rb', line 12 def sort {}.tap do |new_hash| sorted_keys.each do |key| new_hash[key] = change_value(hash[key]) end end end |