class UltraConfig::Config

Attributes

value[R]

Public Class Methods

new(name, parents, options = {}, &block) click to toggle source
# 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

Public Instance Methods

sanitize?() click to toggle source
# File lib/ultra_config/config.rb, line 40
def sanitize?
  @sanitize
end
set() { |intermediate_value| ... } click to toggle source
# File lib/ultra_config/config.rb, line 36
def set(&block)
  @intermediate_value = yield(@intermediate_value)
end
to_s() click to toggle source
# File lib/ultra_config/config.rb, line 44
def to_s
  "\"#{@value.to_s}\""
end
value=(value) click to toggle source
# File lib/ultra_config/config.rb, line 20
def value=(value)
  @intermediate_value = value

  # Be nice and convert Strings to Symbols
  @intermediate_value = @intermediate_value.to_sym if @intermediate_value.is_a?(String) && @value.is_a?(Symbol)

  self.instance_eval(&@config_block) if @config_block
  type_safety(Settings.type_safety) unless @type_safety_checked
  @value = @intermediate_value
rescue UltraConfig::Validation::ValidationError
  raise UltraConfig::Validation::ValidationError.new(@error_msg, @parents + [@name], sanitize? ? '*****' : @intermediate_value)
ensure
  @type_safety_checked = false
  @intermediate_value = nil
end