Class: MediaWikiVagrant::Setting
- Defined in:
- lib/mediawiki-vagrant/setting.rb
Overview
A MediaWiki-Vagrant setting.
Instance Attribute Summary collapse
-
#allows_empty ⇒ true, false
(also: #allows_empty?)
Whether to allow empty string values.
-
#auto ⇒ Proc
Used to automatically configure the setting.
-
#coercion ⇒ Proc
Used to process a given setting value.
-
#combiner ⇒ Proc
Used to make an incremental change to the setting.
-
#default ⇒ Object
Default value.
-
#description ⇒ String
Brief description of the setting.
-
#help ⇒ String
Additional help text.
-
#internal ⇒ true, false
(also: #internal?)
Whether the setting is only used internally.
-
#name ⇒ Symbol
readonly
Name of the setting.
-
#value ⇒ Object
Current value.
Instance Method Summary collapse
- #auto! ⇒ Object
- #combine!(other) ⇒ Object
- #default? ⇒ Boolean
-
#initialize(name, value = nil) ⇒ Setting
constructor
A new instance of Setting.
- #set? ⇒ Boolean
- #unset! ⇒ Object
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_empty ⇒ true, false Also known as: allows_empty?
Whether to allow empty string values
18 19 20 |
# File 'lib/mediawiki-vagrant/setting.rb', line 18 def allows_empty @allows_empty end |
#auto ⇒ Proc
Used to automatically configure the setting
18 19 20 |
# File 'lib/mediawiki-vagrant/setting.rb', line 18 def auto @auto end |
#coercion ⇒ Proc
Used to process a given setting value
18 19 20 |
# File 'lib/mediawiki-vagrant/setting.rb', line 18 def coercion @coercion end |
#combiner ⇒ Proc
Used to make an incremental change to the setting.
18 19 20 |
# File 'lib/mediawiki-vagrant/setting.rb', line 18 def combiner @combiner end |
#default ⇒ Object
Default value
18 19 20 |
# File 'lib/mediawiki-vagrant/setting.rb', line 18 def default @default end |
#description ⇒ String
Brief description of the setting
18 19 20 |
# File 'lib/mediawiki-vagrant/setting.rb', line 18 def description @description end |
#help ⇒ String
Additional help text
18 19 20 |
# File 'lib/mediawiki-vagrant/setting.rb', line 18 def help @help end |
#internal ⇒ true, false Also known as: internal?
Whether the setting is only used internally
18 19 20 |
# File 'lib/mediawiki-vagrant/setting.rb', line 18 def internal @internal end |
#name ⇒ Symbol (readonly)
Name of the setting.
18 19 20 |
# File 'lib/mediawiki-vagrant/setting.rb', line 18 def name @name end |
#value ⇒ Object
Current 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
43 44 45 |
# File 'lib/mediawiki-vagrant/setting.rb', line 43 def default? !@default.nil? end |
#set? ⇒ 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 |