Created
December 14, 2021 06:52
-
-
Save pat/5feba9bf0c122ec5f9c2bf6de5f24c21 to your computer and use it in GitHub Desktop.
Using dry-system for typed and verified Rails configuration settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "dry/system/errors" | |
require "dry/system/settings" | |
require "dry/types" | |
module Types | |
include Dry.Types() | |
end | |
SettingsSchema = Dry::System::Settings::DSL.new do | |
key :domain, Types::Strict::String.default("example.com") | |
key :calendar_url, Types::Strict::String | |
key :twilio_account_id, Types::Strict::String.optional.default(nil) | |
key :twilio_auth_token, Types::Strict::String.optional.default(nil) | |
key :phone_number, Types::Strict::String | |
key :host_phone_number, Types::Strict::String | |
end | |
Settings = SettingsSchema.call.init(Rails.root, Rails.env) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment