Module: B1Config
- Extended by:
- B1Config
- Included in:
- B1Config
- Defined in:
- lib/b1_config.rb,
lib/b1_config/loader.rb,
lib/b1_config/options.rb,
lib/b1_config/version.rb,
lib/b1_config/exception.rb,
lib/generators/b1_config/install_generator.rb
Defined Under Namespace
Modules: Generators Classes: Exception, Loader, Options
Constant Summary collapse
- VERSION =
"1.0"- @@name =
"Settings"- @@env =
"development"- @@load_paths =
[]
Instance Method Summary collapse
-
#add_load_path(path) ⇒ Object
Add directory to config loaded path.
-
#get_const ⇒ Object
Get registered constant.
-
#load_constant ⇒ Object
Load constant.
-
#load_data ⇒ Object
(also: #reload!)
Load data from .yml files in load directories.
-
#remove_load_path(path) ⇒ Object
Remove directory from config loaded path.
-
#setup {|_self| ... } ⇒ Object
Setup moduleand set base params.
Instance Method Details
#add_load_path(path) ⇒ Object
Add directory to config loaded path
39 40 41 42 43 |
# File 'lib/b1_config.rb', line 39 def add_load_path path path = "/" + path.to_s.split("/").reject(&:empty?).join("/") + "/" @@load_paths << path.to_s unless @@load_paths.include?(path.to_s) self end |
#get_const ⇒ Object
Get registered constant
34 35 36 |
# File 'lib/b1_config.rb', line 34 def get_const B1Config.name.constantize end |
#load_constant ⇒ Object
Load constant
21 22 23 24 25 |
# File 'lib/b1_config.rb', line 21 def load_constant Kernel.send(:remove_const, B1Config.name) if Kernel.const_defined?(B1Config.name) Kernel.const_set(B1Config.name, B1Config::Options) self end |
#load_data ⇒ Object Also known as: reload!
Load data from .yml files in load directories
28 29 30 31 |
# File 'lib/b1_config.rb', line 28 def load_data B1Config::Loader.load(@@load_paths) self end |
#remove_load_path(path) ⇒ Object
Remove directory from config loaded path
46 47 48 49 |
# File 'lib/b1_config.rb', line 46 def remove_load_path path @@load_paths.reject!{|pth| path==pth} self end |