Created
November 10, 2022 08:36
-
-
Save leastbad/31c4a94501df2698b89628dffa6ac269 to your computer and use it in GitHub Desktop.
Revisions
-
leastbad created this gist
Nov 10, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ module IndexableByHashPatch refine Array do def to_proc ->(h) { length == 1 ? h[first] : h.values_at(*self) } end end end using IndexableByHashPatch indexed_records = json.index_by(&[:item_type, :item_id])