From 80fd26fad2593b35932f5679dd77e89494af5433 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Wed, 2 Jan 2019 01:36:17 +0900 Subject: [PATCH] FS::Hash#to_h --- src/fs.cr | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/fs.cr b/src/fs.cr index 030e743..aba86ef 100644 --- a/src/fs.cr +++ b/src/fs.cr @@ -116,6 +116,18 @@ class FS::Hash(K, V) end end + ## + # CAUTION: Very slow. Try not to use. + def to_h + hash = ::Hash(K, V).new + + each do |key, value| + hash[key] = value + end + + hash + end + private def file_path(key : K) "#{@directory_name}/#{key.to_s}.json" end