Sha256: 17d6b5075706289d08cb2269b0ebee66380668f3ebd9b9e5201036c5913c80bc

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

# dry-importer <a href="https://gitter.im/dryrb/chat" target="_blank">![Join the chat at https://gitter.im/dryrb/chat](https://badges.gitter.im/Join%20Chat.svg)</a>

<a href="https://rubygems.org/gems/dry-importer" target="_blank">![Gem Version](https://badge.fury.io/rb/dry-importer.svg)</a>
<a href="https://travis-ci.org/dryrb/dry-importer" target="_blank">![Build Status](https://travis-ci.org/dryrb/dry-importer.svg?branch=master)</a>
<a href="https://gemnasium.com/dryrb/dry-importer" target="_blank">![Dependency Status](https://gemnasium.com/dryrb/dry-importer.svg)</a>
<a href="https://codeclimate.com/github/dryrb/dry-importer" target="_blank">![Code Climate](https://codeclimate.com/github/dryrb/dry-importer/badges/gpa.svg)</a>
<a href="http://inch-ci.org/github/dryrb/dry-importer" target="_blank">![Documentation Status](http://inch-ci.org/github/dryrb/dry-importer.svg?branch=master&style=flat)</a>

Import a constant tree into another

## Synopsis

```ruby
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.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-importer-0.0.1 README.md