Class: UltraConfig::Config

Inherits:
Object
  • Object
show all
Includes:
Validation
Defined in:
lib/ultra_config/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validation

#custom, #match, #one_of, #range, #type_safety

Constructor Details

#initialize(name, parents, options = {}, &block) ⇒ Config

Returns a new instance of Config.



10
11
12
13
14
15
16
17
18
# File 'lib/ultra_config/config.rb', line 10

def initialize(name, parents, options = {}, &block)
  @name = name
  @parents = parents
  @config_block = block

  @value = options[:default].nil? ? nil : options[:default]
  @sanitize = options[:sanitize] || false
  @error_msg = options[:error_msg]
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



8
9
10
# File 'lib/ultra_config/config.rb', line 8

def value
  @value
end

Instance Method Details

#sanitize?Boolean

Returns:



36
37
38
# File 'lib/ultra_config/config.rb', line 36

def sanitize?
  @sanitize
end

#set(&block) ⇒ Object



32
33
34
# File 'lib/ultra_config/config.rb', line 32

def set(&block)
  @intermediate_value = yield(@intermediate_value)
end

#to_sObject



40
41
42
# File 'lib/ultra_config/config.rb', line 40

def to_s
  "\"#{@value.to_s}\""
end