Class: Middleman::Configuration::ConfigSetting

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#defaultObject

The default value for this setting



205
206
207
# File 'lib/middleman-core/configuration.rb', line 205

def default
  @default
end

#descriptionObject

A human-friendly description of the setting



208
209
210
# File 'lib/middleman-core/configuration.rb', line 208

def description
  @description
end

#keyObject

The name of this setting



202
203
204
# File 'lib/middleman-core/configuration.rb', line 202

def key
  @key
end

Instance Method Details

#valueObject

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

Returns:

  • (Boolean)


232
233
234
# File 'lib/middleman-core/configuration.rb', line 232

def value_set?
  @value_set
end