dry-rb / dry-inflector

Inflector for Ruby
https://dry-rb.org/gems/dry-inflector
MIT License
95 stars 15 forks source link

Add Zeitwerk autoloader #42

Open solnic opened 2 years ago

Ptico commented 1 year ago

I'm looking at the implementation in other gems and have a question: would it work if we will make zeitwerk a soft dependency?

I mean, for the zeitwerk environments it's already added to Gemfile, so we may do something like:

require "zeitwerk" rescue nil

class Inflector 

  if defined?(Zeitwerk)
    def self.loader
      # ...
    end
  end

If so, the power of Zeitwerk will be added without introducing new dependencies for those who don't need it

solnic commented 1 year ago

This wouldn't be enough. We'd also have to make explicit requires optional depending on the presence of Zeitwerk.