Sha256: 77b6a12dce29c6287f5d3d023008d6d50061f96ae59e3e3670d9daeb09fcc737

Contents?: true

Size: 665 Bytes

Versions: 1

Compression:

Stored size: 665 Bytes

Contents

module Quickery
  class Railtie < Rails::Railtie
    # Need to eager load all models so that all quickery callbacks and dependencies will be considered
    config.after_initialize do |app|
      # unless Rails app is already set to eager_load
      unless app.config.eager_load
        models_load_path = File.join(Rails.root, 'app', 'models')

        # copied from https://apidock.com/rails/Rails/Engine/eager_load%21/class
        matcher = /\A#{Regexp.escape(models_load_path.to_s)}\/(.*)\.rb\Z/
        Dir.glob("#{models_load_path}/**/*.rb").sort.each do |file|
          app.require_dependency file.sub(matcher, '\1')
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quickery-0.1.3 lib/quickery/railtie.rb