API improvements.

```
p = hash.new_partition("table-name")
p.get "partition-name"
```

Also works for indices and tags.
remotes/1702071717368387340/master
Luka Vandervelden 2019-12-11 17:58:35 +01:00
parent 70209f963e
commit ca712f98ce
1 changed files with 9 additions and 3 deletions

View File

@ -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)