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.
-
#options ⇒ Object
Additional config.
Instance Method Summary collapse
-
#initialize(key, default, description, options = {}) ⇒ 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, options = {}) ⇒ ConfigSetting
Returns a new instance of ConfigSetting.
130 131 132 133 134 135 136 |
# File 'lib/middleman-core/configuration.rb', line 130 def initialize(key, default, description, ={}) @value_set = false self.key = key self.default = default self.description = description self. = end |
Instance Attribute Details
#default ⇒ Object
The default value for this setting
122 123 124 |
# File 'lib/middleman-core/configuration.rb', line 122 def default @default end |
#description ⇒ Object
A human-friendly description of the setting
125 126 127 |
# File 'lib/middleman-core/configuration.rb', line 125 def description @description end |
#key ⇒ Object
The name of this setting
119 120 121 |
# File 'lib/middleman-core/configuration.rb', line 119 def key @key end |
#options ⇒ Object
Additional config.
128 129 130 |
# File 'lib/middleman-core/configuration.rb', line 128 def @options 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.
147 148 149 |
# File 'lib/middleman-core/configuration.rb', line 147 def value value_set? ? @value : default end |
#value=(value) ⇒ Object
The user-supplied value for this setting, overriding the default
139 140 141 142 |
# File 'lib/middleman-core/configuration.rb', line 139 def value=(value) @value = value @value_set = true end |
#value_set? ⇒ Boolean
Whether or not there has been a value set beyond the default
152 153 154 |
# File 'lib/middleman-core/configuration.rb', line 152 def value_set? @value_set == true end |