dry-importer
Import a constant tree into another
Synopsis
module BaseLibrary
class SomeClass
def self.base_method
'base'
end
end
class Tool
def self.get_base_method
namespace::SomeClass.base_method
end
private
def self.namespace
Module.const_get(self.to_s[/(.*)(?=::)/])
end
end
end
module ExtensionLibrary
Dry::Importer.import(self, BaseLibrary)
class SomeClass
def self.base_method
"was #{super}"
end
end
end
BaseLibrary::Tool.get_base_method
# => "base"
ExtensionLibrary::Tool.get_base_method
# => "was base"
License
See LICENSE
file.