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.



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

#defaultObject

The default value for this setting



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

def default
  @default
end

#descriptionObject

A human-friendly description of the setting



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

def description
  @description
end

#keyObject

The name of this setting



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

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.



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

Returns:

  • (Boolean)


230
231
232
# File 'lib/middleman-core/configuration.rb', line 230

def value_set?
  @value_set
end