Created
January 29, 2024 13:22
-
-
Save tcannonfodder/23c47e8557a717ab167be377dd458ad4 to your computer and use it in GitHub Desktop.
Configuration PORO
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 | |
class AppSettings | |
def self.env_fetch(method_name:, key:) | |
define_singleton_method(method_name){ ENV.fetch(key) } | |
end | |
env_fetch(method_name: :webserver_port, key: "PORT") | |
env_fetch(method_name: :default_host, key: "DEFAULT_HOST") | |
env_fetch(method_name: :relying_party_origin, key: "RELYING_PARTY_ORIGIN") | |
env_fetch(method_name: :support_url, key: "SUPPORT_URL") | |
env_fetch(method_name: :support_email, key: "SUPPORT_EMAIL") | |
env_fetch(method_name: :postmark_api_token, key: "POSTMARK_API_TOKEN") | |
def self.rails_semantic_logger_format | |
ENV.fetch("RAILS_SEMANTIC_LOGGER_FORMAT") { nil } | |
end | |
def self.default_host_uri | |
URI.parse("https://#{self.default_host}") | |
end | |
def self.generate_uri(subdomain:) | |
uri = default_host_uri | |
uri.host = uri.host.prepend(subdomain.to_s, ".") | |
return uri | |
end | |
def self.default_url_options | |
{ host: self.default_host, protocol: :https } | |
end | |
end |
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
// Example Swift configuration Actor; where the idea originated | |
actor WorkoutAppConfiguration { | |
static let instance = WorkoutAppConfiguration() | |
public let authenticationSessionSchema: String | |
public let HealthKitIdentifier: String | |
init(){ | |
self.authenticationSessionSchema = Bundle.main.infoDictionary!["AUTHENTICATION_SERVICES_CALLBACK_SCHEME"] as! String | |
self.HealthKitIdentifier = Bundle.main.infoDictionary!["HEALTH_KIT_IDENTIFIER"] as! String | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment