From ca712f98ce75ad04b9071c45d9fbce947587dc70 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Wed, 11 Dec 2019 17:58:35 +0100 Subject: [PATCH] API improvements. ``` p = hash.new_partition("table-name") p.get "partition-name" ``` Also works for indices and tags. --- src/fs.cr | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/fs.cr b/src/fs.cr index 3683b3f..d5335c7 100644 --- a/src/fs.cr +++ b/src/fs.cr @@ -213,17 +213,23 @@ class FS::Hash(K, V) ## # name is the name that will be used on the file system. def new_partition(name : String, &block : Proc(V, String)) - @indexers << Partition(V).new @directory_name, name, block + Partition(V).new(@directory_name, name, block).tap do |table| + @indexers << table + end end ## # name is the name that will be used on the file system. def new_index(name : String, &block : Proc(V, String)) - @indexers << Index(V).new @directory_name, name, block + Index(V).new(@directory_name, name, block).tap do |indexer| + @indexers << indexer + end end def new_tags(name : String, &block : Proc(V, Array(String))) - @indexers << Tags(V).new @directory_name, name, block + Tags(V).new(@directory_name, name, block).tap do |tags| + @indexers << tags + end end def get_index(name : String, key)