Class: Konfig::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/konfig.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#allow_nilObject



81
82
83
# File 'lib/konfig.rb', line 81

def allow_nil
  @allow_nil.nil? ? true : @allow_nil
end

#default_config_filesObject



73
74
75
76
77
78
79
# File 'lib/konfig.rb', line 73

def default_config_files
  if defined?(Rails)
    @default_config_files || ["#{Rails.env.downcase}.yml", "#{Rails.env.downcase}.local.yml"]
  else
    @default_config_files || ["development.yml", "development.local.yml"]
  end
end

#delimiterObject



69
70
71
# File 'lib/konfig.rb', line 69

def delimiter
  @delimiter || "."
end

#env_prefixObject



31
32
33
# File 'lib/konfig.rb', line 31

def env_prefix
  @env_prefix || "KONFIG"
end

#fail_on_validationObject



89
90
91
# File 'lib/konfig.rb', line 89

def fail_on_validation
	@fail_on_validation.nil? ? true : @fail_on_validation
end

#loggerObject



47
48
49
50
51
52
53
54
55
# File 'lib/konfig.rb', line 47

def logger
  return @logger if @logger
  if defined?(Rails) && Rails.logger
    @logger = Rails.logger
  else
    @logger = Logger.new(STDOUT)
  end
  @logger
end

#modeObject

Raises:



41
42
43
44
45
# File 'lib/konfig.rb', line 41

def mode
  raise NotConfiguredError, "have you set mode?" unless @mode

  @mode
end

#namespaceObject



27
28
29
# File 'lib/konfig.rb', line 27

def namespace
  @namespace || "Settings"
end

#nil_wordObject



85
86
87
# File 'lib/konfig.rb', line 85

def nil_word
     @nil_word || "null"
end

#workdirObject

Raises:



35
36
37
38
39
# File 'lib/konfig.rb', line 35

def workdir
  raise NotConfiguredError, "have you set workdir?" unless @workdir

  @workdir
end

Instance Method Details

#schema(&block) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/konfig.rb', line 61

def schema(&block)
  if block_given?
    @schema = Dry::Schema.define(&block)
  else
    @schema
  end
end

#schema=(value) ⇒ Object



57
58
59
# File 'lib/konfig.rb', line 57

def schema=(value)
  @schema = value
end