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 =
3
- PATCH =
0
- PRERELEASE =
nil
- VERSION =
[MAJOR, MINOR, PATCH, PRERELEASE].compact.join(".")
Class Method Summary
collapse
Class Method Details
.cache ⇒ Object
11
12
13
|
# File 'lib/confg.rb', line 11
def cache
@cache ||= {}
end
|
.config(env: self.env, root: self.root) {|out| ... } ⇒ Object
Also known as:
configure
34
35
36
37
38
39
|
# File 'lib/confg.rb', line 34
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
21
22
23
24
25
|
# File 'lib/confg.rb', line 21
def env
return @env if defined?(@env)
@env = calc_env_string
end
|
.erb_function(function_name, &block) ⇒ Object
27
28
29
30
31
32
|
# File 'lib/confg.rb', line 27
def erb_function(function_name, &block)
::Confg::ErbContext.class_eval do
define_method(function_name, &block)
end
self
end
|
.method_missing(method_name) ⇒ Object
42
43
44
|
# File 'lib/confg.rb', line 42
def method_missing(method_name, ...)
config.send(method_name, ...)
end
|
.respond_to_missing? ⇒ Boolean
46
47
48
|
# File 'lib/confg.rb', line 46
def respond_to_missing?(...)
true
end
|
.root ⇒ Object
15
16
17
18
19
|
# File 'lib/confg.rb', line 15
def root
return @root if defined?(@root)
@root = calc_root_path
end
|