Class: Konfig::Config
- Inherits:
-
Object
- Object
- Konfig::Config
- Defined in:
- lib/konfig.rb
Instance Attribute Summary collapse
- #allow_nil ⇒ Object
- #default_config_files ⇒ Object
- #delimiter ⇒ Object
- #env_prefix ⇒ Object
- #fail_on_validation ⇒ Object
- #logger ⇒ Object
- #mode ⇒ Object
- #namespace ⇒ Object
- #nil_word ⇒ Object
- #workdir ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#allow_nil ⇒ Object
81 82 83 |
# File 'lib/konfig.rb', line 81 def allow_nil @allow_nil.nil? ? true : @allow_nil end |
#default_config_files ⇒ Object
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 |
#delimiter ⇒ Object
69 70 71 |
# File 'lib/konfig.rb', line 69 def delimiter @delimiter || "." end |
#env_prefix ⇒ Object
31 32 33 |
# File 'lib/konfig.rb', line 31 def env_prefix @env_prefix || "KONFIG" end |
#fail_on_validation ⇒ Object
89 90 91 |
# File 'lib/konfig.rb', line 89 def fail_on_validation @fail_on_validation.nil? ? true : @fail_on_validation end |
#logger ⇒ Object
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 |
#mode ⇒ Object
41 42 43 44 45 |
# File 'lib/konfig.rb', line 41 def mode raise NotConfiguredError, "have you set mode?" unless @mode @mode end |
#namespace ⇒ Object
27 28 29 |
# File 'lib/konfig.rb', line 27 def namespace @namespace || "Settings" end |
#nil_word ⇒ Object
85 86 87 |
# File 'lib/konfig.rb', line 85 def nil_word @nil_word || "null" end |
#workdir ⇒ Object
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 |