module Latch
Included Modules
- Habitat::SettingsHelpers
- Habitat::TempConfig
Defined in:
latch/base.crlatch/config.cr
latch/uploaded_file.cr
latch/utilities.cr
latch/version.cr
Constant Summary
-
HABITAT_SETTINGS =
[{decl: storages : Hash(String, Storage) = {} of String => Storage, example: nil, validation: nil}, {decl: path_prefix : String = ":model/:id/:attachment", example: nil, validation: nil}] of Nil -
VERSION =
{{ (`shards version \"/home/runner/work/latch/latch/src/latch\"`).chomp.stringify }}
Class Method Summary
- .configure(&)
-
.find_storage(name : String) : Storage
Retrieves a storage by name, raising if not found.
- .settings
-
.with_file(io : IO, &)
Utility to work with a file IO.
- .with_file(uploaded_file : StoredFile, &)
Instance Method Summary
Class Method Detail
Retrieves a storage by name, raising if not found.
Latch.find_storage("store") # => Storage::FileSystem
Latch.find_storage("missing") # raises Latch::Error
def self.with_file(io : IO, &)
#
Utility to work with a file IO. If the IO is already a File, yields it directly, Otherwise copies to a tempfile, yields it, then cleans up.
Latch.with_file(io) do |file|
# file is guaranteed to be a File with a path
end