Use Pathname for storage_path
https://claude.ai/code/session_018Ym45siELMvsBQj4w9QAXf
diff --git a/lib/app.rb b/lib/app.rb
index 136c78f..f72658a 100644
--- a/lib/app.rb
+++ b/lib/app.rb
@@ -13,7 +13,7 @@ module Domus
end
def file_path(record)
- ::File.join(config.storage_path, "files", "#{record[:id]}#{record[:extension]}")
+ config.storage_path / "files" / "#{record[:id]}#{record[:extension]}"
end
end
end
diff --git a/lib/config.rb b/lib/config.rb
index 0081047..4200726 100644
--- a/lib/config.rb
+++ b/lib/config.rb
@@ -1,17 +1,19 @@
# rbs_inline: enabled
# frozen_string_literal: true
+require "pathname"
+
module Domus
Config = Data.define(
:database_url, #: String
- :storage_path #: String
+ :storage_path #: Pathname
)
class Config
#: () -> Config
def self.env = new(
database_url: ENV.fetch("DATABASE_URL") { "db/domus.db" },
- storage_path: ENV.fetch("STORAGE_PATH") { "storage" },
+ storage_path: Pathname(ENV.fetch("STORAGE_PATH") { "storage" }),
)
end
end