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.
Constructor Details
#initialize(key, default, description) ⇒ ConfigSetting
Returns a new instance of ConfigSetting.
209 210 211 212 213 214 |
# File 'lib/middleman-core/configuration.rb', line 209 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
204 205 206 |
# File 'lib/middleman-core/configuration.rb', line 204 def default @default end |
#description ⇒ Object
A human-friendly description of the setting
207 208 209 |
# File 'lib/middleman-core/configuration.rb', line 207 def description @description end |
#key ⇒ Object
The name of this setting
201 202 203 |
# File 'lib/middleman-core/configuration.rb', line 201 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.
225 226 227 |
# File 'lib/middleman-core/configuration.rb', line 225 def value value_set? ? @value : default end |
#value=(value) ⇒ Object
The user-supplied value for this setting, overriding the default
217 218 219 220 |
# File 'lib/middleman-core/configuration.rb', line 217 def value=(value) @value = value @value_set = true end |
#value_set? ⇒ Boolean
Whether or not there has been a value set beyond the default
230 231 232 |
# File 'lib/middleman-core/configuration.rb', line 230 def value_set? @value_set end |