Module: Configue::ClassMethod
- Defined in:
- lib/configue/importer.rb
Instance Method Summary collapse
-
#import_config(args) ⇒ Object
Imports a configuration as one of attributes.
Instance Method Details
#import_config(args) ⇒ Object
Imports a configuration as one of attributes.
The following keys are available:
as
-
(required) a name of an attribute for the configuration.
from_dir
-
a path of a directory that the configuration file is in.
from_file
-
a path of the configuration file.
namespace
-
a name of namespace.
base_namespace
-
a name of base namespace.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/configue/importer.rb', line 21 def import_config(args) raise ArgumentError unless args.respond_to?(:[]) var = args.delete(:as) || 'config' dirs = args.delete(:from_dir) files = args.delete(:from_file) args[:source_dir] = dirs if dirs args[:source_file] = files if files config = Class.new(Container) args.each {|k, v| config.config.__send__(k, *Array(v)) } define_method(var, -> { config }) nil end |