Sha256: b41c2490ae7811805502c6176e4c98e9cc1dff5d194e46c18424c78526fb8a93

Contents?: true

Size: 690 Bytes

Versions: 6

Compression:

Stored size: 690 Bytes

Contents

require 'rails/railtie'

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

6 entries across 6 versions & 1 rubygems

Version Path
quickery-1.3.1 lib/quickery/railtie.rb
quickery-1.3.0 lib/quickery/railtie.rb
quickery-1.2.0 lib/quickery/railtie.rb
quickery-1.1.0 lib/quickery/railtie.rb
quickery-1.0.0 lib/quickery/railtie.rb
quickery-0.1.4 lib/quickery/railtie.rb