Sha256: f7788cb56d6214bd49d18792eaa41ad2e00d1f8f5a7f55f32002095428d220eb

Contents?: true

Size: 634 Bytes

Versions: 8

Compression:

Stored size: 634 Bytes

Contents

require 'lhc'

module LHS
  class RequireLhsRecords
    def initialize(app)
      @app = app
    end

    def call(env)
      Dir.glob(Rails.root.join('app/models/**/*.rb')).each do |file|
        require_dependency file if File.read(file).match('LHS::Record')
      end
      @app.call(env)
    end
  end
end

Gem.find_files('lhs/**/*.rb').sort.each { |path| require path }

# Preload all the LHS::Records that are defined in app/models
class Engine < Rails::Engine
  initializer 'Load all LHS::Records from app/models/**' do |app|
    next if app.config.cache_classes

    app.config.middleware.use LHS::RequireLhsRecords
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lhs-9.1.0 lib/lhs.rb
lhs-9.0.4 lib/lhs.rb
lhs-9.0.3 lib/lhs.rb
lhs-9.0.2 lib/lhs.rb
lhs-9.0.1 lib/lhs.rb
lhs-9.0.0 lib/lhs.rb
lhs-8.0.0 lib/lhs.rb
lhs-7.4.1 lib/lhs.rb