Class: Middleman::Configuration::ConfigSetting
- Inherits:
-
Object
- Object
- Middleman::Configuration::ConfigSetting
- Defined in:
- lib/middleman-core/configuration.rb
Overview
An individual configuration setting, with an optional default and description. Also models whether or not a value has been set.
Instance Attribute Summary collapse
-
#default ⇒ Object
The default value for this setting.
-
#description ⇒ Object
A human-friendly description of the setting.
-
#key ⇒ Object
The name of this setting.
Instance Method Summary collapse
-
#initialize(key, default, description) ⇒ ConfigSetting
constructor
A new instance of ConfigSetting.
-
#value ⇒ Object
The effective value of the setting, which may be the default if the user has not set a value themselves.
-
#value=(value) ⇒ Object
The user-supplied value for this setting, overriding the default.
-
#value_set? ⇒ Boolean
Whether or not there has been a value set beyond the default rubocop:disable TrivialAccessors.
Constructor Details
#initialize(key, default, description) ⇒ ConfigSetting
Returns a new instance of ConfigSetting.
210 211 212 213 214 215 |
# File 'lib/middleman-core/configuration.rb', line 210 def initialize(key, default, description) @value_set = false self.key = key self.default = default self.description = description end |
Instance Attribute Details
#default ⇒ Object
The default value for this setting
205 206 207 |
# File 'lib/middleman-core/configuration.rb', line 205 def default @default end |
#description ⇒ Object
A human-friendly description of the setting
208 209 210 |
# File 'lib/middleman-core/configuration.rb', line 208 def description @description end |
#key ⇒ Object
The name of this setting
202 203 204 |
# File 'lib/middleman-core/configuration.rb', line 202 def key @key end |
Instance Method Details
#value ⇒ Object
The effective value of the setting, which may be the default if the user has not set a value themselves. Note that even if the user sets the value to nil it will override the default.
226 227 228 |
# File 'lib/middleman-core/configuration.rb', line 226 def value value_set? ? @value : default end |
#value=(value) ⇒ Object
The user-supplied value for this setting, overriding the default
218 219 220 221 |
# File 'lib/middleman-core/configuration.rb', line 218 def value=(value) @value = value @value_set = true end |
#value_set? ⇒ Boolean
Whether or not there has been a value set beyond the default rubocop:disable TrivialAccessors
232 233 234 |
# File 'lib/middleman-core/configuration.rb', line 232 def value_set? @value_set end |