Class: Darthjee::CoreExt::Hash::KeysSorter Private
- Defined in:
- lib/darthjee/core_ext/hash/keys_sorter.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class responsible for sorting keys of a Hash
Instance Method Summary collapse
-
#initialize(hash, recursive: true) ⇒ KeysSorter
constructor
private
A new instance of KeysSorter.
-
#sort ⇒ ::Hash
private
Creates a new Hash sorting it's keys.
Constructor Details
#initialize(hash, recursive: true) ⇒ KeysSorter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of KeysSorter.
16 17 18 19 |
# File 'lib/darthjee/core_ext/hash/keys_sorter.rb', line 16 def initialize(hash, recursive: true) @hash = hash @recursive = recursive end |
Instance Method Details
#sort ⇒ ::Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new Hash sorting it's keys
35 36 37 38 39 40 41 |
# File 'lib/darthjee/core_ext/hash/keys_sorter.rb', line 35 def sort hash.tap do sorted_keys.each do |key| hash[key] = change_value(hash.delete(key)) end end end |