Module: Confg
- Defined in:
- lib/confg.rb,
lib/confg/version.rb,
lib/confg/erb_context.rb,
lib/confg/configuration.rb
Defined Under Namespace
Classes: Configuration, ErbContext
Constant Summary
collapse
- MAJOR =
3
- MINOR =
4
- PATCH =
2
- PRERELEASE =
nil
- VERSION =
[MAJOR, MINOR, PATCH, PRERELEASE].compact.join(".")
Class Method Summary
collapse
Class Method Details
.cache ⇒ Object
13
14
15
|
# File 'lib/confg.rb', line 13
def cache
@cache ||= {}
end
|
.config(env: self.env, root: self.root) {|out| ... } ⇒ Object
Also known as:
configure
36
37
38
39
40
41
|
# File 'lib/confg.rb', line 36
def config(env: self.env, root: self.root)
config_key = "#{env}--#{root}"
out = (cache[config_key] ||= ::Confg::Configuration.new(env: env, root: root))
yield out if block_given?
out
end
|
.env ⇒ Object
23
24
25
26
27
|
# File 'lib/confg.rb', line 23
def env
return @env if defined?(@env)
@env = calc_env_string
end
|
.erb_function(function_name, &block) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/confg.rb', line 29
def erb_function(function_name, &block)
::Confg::ErbContext.class_eval do
define_method(function_name, &block)
end
self
end
|
.method_missing(method_name) ⇒ Object
44
45
46
|
# File 'lib/confg.rb', line 44
def method_missing(method_name, ...)
config.send(method_name, ...)
end
|
.respond_to_missing? ⇒ Boolean
48
49
50
|
# File 'lib/confg.rb', line 48
def respond_to_missing?(...)
true
end
|
.root ⇒ Object
17
18
19
20
21
|
# File 'lib/confg.rb', line 17
def root
return @root if defined?(@root)
@root = calc_root_path
end
|