Class: ModulePlus::ConfigDef
- Inherits:
-
Object
- Object
- ModulePlus::ConfigDef
- Defined in:
- lib/module_plus/config_convention.rb
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#sample ⇒ Object
readonly
Returns the value of attribute sample.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #field ⇒ Object
-
#initialize(key, path, attributes = {}) ⇒ ConfigDef
constructor
A new instance of ConfigDef.
- #value(v) ⇒ Object
Constructor Details
#initialize(key, path, attributes = {}) ⇒ ConfigDef
Returns a new instance of ConfigDef.
134 135 136 137 138 139 140 141 |
# File 'lib/module_plus/config_convention.rb', line 134 def initialize(key, path, attributes = {}) @key = key.to_s @path = path @desc = attributes[:desc] || "" @type = _type(attributes[:type]) @type_strict = _type_strict(@type) @sample = attributes[:sample] || _sample(@type) end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
133 134 135 |
# File 'lib/module_plus/config_convention.rb', line 133 def desc @desc end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
133 134 135 |
# File 'lib/module_plus/config_convention.rb', line 133 def key @key end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
133 134 135 |
# File 'lib/module_plus/config_convention.rb', line 133 def path @path end |
#sample ⇒ Object (readonly)
Returns the value of attribute sample.
133 134 135 |
# File 'lib/module_plus/config_convention.rb', line 133 def sample @sample end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
133 134 135 |
# File 'lib/module_plus/config_convention.rb', line 133 def type @type end |
Instance Method Details
#field ⇒ Object
143 144 145 |
# File 'lib/module_plus/config_convention.rb', line 143 def field "#{@path.join(".")}.#{@key}" end |
#value(v) ⇒ Object
147 148 149 150 |
# File 'lib/module_plus/config_convention.rb', line 147 def value(v) raise new NotPermitedValueType.new("#{path}.#{@key}: #{v} is NOT Matched Type for #{@type}") unless @type_strict.call(v) v end |