Class: Plutonium::Configuration
- Inherits:
-
Object
- Object
- Plutonium::Configuration
- Defined in:
- lib/plutonium/configuration.rb
Overview
Configuration class for Plutonium module
Defined Under Namespace
Classes: AssetConfiguration
Constant Summary collapse
- VERSION_DEFAULTS =
Map of version numbers to their default configurations
{ 1.0 => proc do |config| # No changes for 1.0 yet as it's the current base configuration end # Add more version configurations here as needed # 1.1 => proc do |config| # config.some_new_setting = true # end }.freeze
Instance Attribute Summary collapse
-
#assets ⇒ AssetConfiguration
readonly
Asset configuration.
-
#cache_discovery ⇒ Boolean
Whether to cache discovery.
-
#default_currency_unit ⇒ String, ...
The currency unit (symbol) used when rendering a currency value that has no unit configured on
has_centsor the display. -
#default_phone_country ⇒ String?
The default country (ISO2 code, e.g. "gh") for phone (
as: :phone) inputs that don't set their owninitial_country:. -
#defaults_version ⇒ Float
readonly
The current defaults version.
-
#development ⇒ Boolean
Whether Plutonium is in development mode.
-
#enable_hotreload ⇒ Boolean
Whether to enable hot reloading.
-
#navii_host_url ⇒ String
Host URL of the Navii avatar service (no path), used by UI::Avatar as the default profile-image fallback.
-
#shell ⇒ Symbol
:modern (Topbar/IconRail, default), :plain (Topbar, no icon rail), or :classic (legacy Header/Sidebar).
-
#wizards ⇒ Plutonium::Wizard::Configuration
readonly
Wizard subsystem configuration.
Instance Method Summary collapse
-
#development? ⇒ Boolean
whether Plutonium is in development mode.
-
#initialize ⇒ Configuration
constructor
Initialize a new Configuration instance.
-
#load_defaults(version) ⇒ void
Load default configuration for a specific version.
Constructor Details
#initialize ⇒ Configuration
This method sets initial values
Initialize a new Configuration instance
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/plutonium/configuration.rb', line 69 def initialize @defaults_version = nil @assets = AssetConfiguration.new @wizards = Plutonium::Wizard::Configuration.new @development = parse_boolean_env("PLUTONIUM_DEV") @cache_discovery = !Rails.env.development? @enable_hotreload = Rails.env.development? @shell = :modern @navii_host_url = "https://api.navii.dev" end |
Instance Attribute Details
#assets ⇒ AssetConfiguration (readonly)
Returns asset configuration.
25 26 27 |
# File 'lib/plutonium/configuration.rb', line 25 def assets @assets end |
#cache_discovery ⇒ Boolean
Returns whether to cache discovery.
19 20 21 |
# File 'lib/plutonium/configuration.rb', line 19 def cache_discovery @cache_discovery end |
#default_currency_unit ⇒ String, ...
Returns the currency unit (symbol) used when rendering
a currency value that has no unit configured on has_cents or the display.
nil (default) falls back to the i18n number.currency.format.unit when
the locale defines it, otherwise no symbol. Set a literal like "£" to
change the default, or false (or "") for no symbol application-wide.
48 49 50 |
# File 'lib/plutonium/configuration.rb', line 48 def default_currency_unit @default_currency_unit end |
#default_phone_country ⇒ String?
Returns the default country (ISO2 code, e.g. "gh") for phone
(as: :phone) inputs that don't set their own initial_country:. nil
(default) leaves it to the intl-tel-input library (no country preselected).
53 54 55 |
# File 'lib/plutonium/configuration.rb', line 53 def default_phone_country @default_phone_country end |
#defaults_version ⇒ Float (readonly)
Returns the current defaults version.
31 32 33 |
# File 'lib/plutonium/configuration.rb', line 31 def defaults_version @defaults_version end |
#development ⇒ Boolean
Returns whether Plutonium is in development mode.
16 17 18 |
# File 'lib/plutonium/configuration.rb', line 16 def development @development end |
#enable_hotreload ⇒ Boolean
Returns whether to enable hot reloading.
22 23 24 |
# File 'lib/plutonium/configuration.rb', line 22 def enable_hotreload @enable_hotreload end |
#navii_host_url ⇒ String
Returns host URL of the Navii avatar service (no path), used by
UI::Avatar as the default profile-image fallback. The
component appends the /avatar/:seed route. Repoint this to self-host
or proxy the service.
41 42 43 |
# File 'lib/plutonium/configuration.rb', line 41 def navii_host_url @navii_host_url end |
#shell ⇒ Symbol
Returns :modern (Topbar/IconRail, default), :plain (Topbar, no icon rail), or :classic (legacy Header/Sidebar).
35 36 37 |
# File 'lib/plutonium/configuration.rb', line 35 def shell @shell end |
#wizards ⇒ Plutonium::Wizard::Configuration (readonly)
Returns wizard subsystem configuration.
28 29 30 |
# File 'lib/plutonium/configuration.rb', line 28 def wizards @wizards end |
Instance Method Details
#development? ⇒ Boolean
whether Plutonium is in development mode
103 104 105 |
# File 'lib/plutonium/configuration.rb', line 103 def development? @development end |
#load_defaults(version) ⇒ void
This method returns an undefined value.
Load default configuration for a specific version
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/plutonium/configuration.rb', line 85 def load_defaults(version) available_versions = VERSION_DEFAULTS.keys.sort applicable_versions = available_versions.select { |v| v <= version } if applicable_versions.empty? raise "No applicable defaults found for version #{version}." end applicable_versions.each do |v| VERSION_DEFAULTS[v].call(self) end @defaults_version = applicable_versions.last end |