Class: MediaWikiVagrant::Setting

Inherits:
Object
  • Object
show all
Defined in:
lib/mediawiki-vagrant/setting.rb

Overview

A MediaWiki-Vagrant setting.

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value = nil) ⇒ Setting

Returns a new instance of Setting.



22
23
24
25
26
27
28
29
# File 'lib/mediawiki-vagrant/setting.rb', line 22

def initialize(name, value = nil)
  @name = name
  @value = value
  @coercion = ->(_, new) { new }
  @combiner = ->(_, new) { new }
  @internal = false
  @allows_empty = false
end

Instance Attribute Details

#allows_emptytrue, false Also known as: allows_empty?

Whether to allow empty string values

Returns:

  • (true, false)

    the current value of allows_empty



18
19
20
# File 'lib/mediawiki-vagrant/setting.rb', line 18

def allows_empty
  @allows_empty
end

#autoProc

Used to automatically configure the setting

Returns:

  • (Proc)

    the current value of auto



18
19
20
# File 'lib/mediawiki-vagrant/setting.rb', line 18

def auto
  @auto
end

#coercionProc

Used to process a given setting value

Returns:

  • (Proc)

    the current value of coercion



18
19
20
# File 'lib/mediawiki-vagrant/setting.rb', line 18

def coercion
  @coercion
end

#combinerProc

Used to make an incremental change to the setting.

Returns:

  • (Proc)

    the current value of combiner



18
19
20
# File 'lib/mediawiki-vagrant/setting.rb', line 18

def combiner
  @combiner
end

#defaultObject

Default value

Returns:

  • (Object)

    the current value of default



18
19
20
# File 'lib/mediawiki-vagrant/setting.rb', line 18

def default
  @default
end

#descriptionString

Brief description of the setting

Returns:

  • (String)

    the current value of description



18
19
20
# File 'lib/mediawiki-vagrant/setting.rb', line 18

def description
  @description
end

#helpString

Additional help text

Returns:

  • (String)

    the current value of help



18
19
20
# File 'lib/mediawiki-vagrant/setting.rb', line 18

def help
  @help
end

#internaltrue, false Also known as: internal?

Whether the setting is only used internally

Returns:

  • (true, false)

    the current value of internal



18
19
20
# File 'lib/mediawiki-vagrant/setting.rb', line 18

def internal
  @internal
end

#nameSymbol (readonly)

Name of the setting.

Returns:

  • (Symbol)

    the current value of name



18
19
20
# File 'lib/mediawiki-vagrant/setting.rb', line 18

def name
  @name
end

#valueObject

Current value

Returns:

  • (Object)

    the current value of value



18
19
20
# File 'lib/mediawiki-vagrant/setting.rb', line 18

def value
  @value
end

Instance Method Details

#auto!Object



33
34
35
# File 'lib/mediawiki-vagrant/setting.rb', line 33

def auto!
  self.value = @auto.call unless @auto.nil? || set?
end

#combine!(other) ⇒ Object



39
40
41
# File 'lib/mediawiki-vagrant/setting.rb', line 39

def combine!(other)
  self.value = @combiner.call(self, other)
end

#default?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/mediawiki-vagrant/setting.rb', line 43

def default?
  !@default.nil?
end

#set?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/mediawiki-vagrant/setting.rb', line 47

def set?
  !@value.nil?
end

#unset!Object



51
52
53
# File 'lib/mediawiki-vagrant/setting.rb', line 51

def unset!
  @value = nil
end