Module: Dry::Importer
- Defined in:
- lib/dry/importer.rb,
lib/dry/importer/version.rb
Constant Summary collapse
- WRAPPER_MAP =
{ Class => ->(const) { Class.new(const) }, Module => ->(const) { Module.new.extend(const) } }
- NOOP =
->(const) { const }
- VERSION =
'0.0.1'.freeze
Class Method Summary collapse
Class Method Details
.import(target, namespace) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/dry/importer.rb', line 13 def import(target, namespace) namespace.constants(false).each do |constant| namespace.const_get(constant).tap do |const| ns = target.const_set(constant, WRAPPER_MAP.fetch(const.class, NOOP).call(const)) import(ns, const) if const.respond_to?(:constants) end end end |