Sha256: 9c631827696104a140e576005b9e7d0ac46595aca1e8454817c128ff603f50db
Contents?: true
Size: 1.32 KB
Versions: 6
Compression:
Stored size: 1.32 KB
Contents
require "rails/railtie" module Trailblazer class Railtie < ::Rails::Railtie def self.autoload_operations(app) Dir.glob("app/concepts/**/crud.rb") do |f| path = f.sub("app/concepts/", "") model = path.sub("/crud.rb", "") require_dependency "#{app.root}/app/models/#{model}" # load the model file, first (thing.rb). require_dependency "#{app.root}/#{f}" # load app/concepts/{concept}/crud.rb (Thing::Create, Thing::Update, and so on). end end def self.autoload_cells(app) Dir.glob("app/concepts/**/*cell.rb") do |f| require_dependency "#{app.root}/#{f}" # load app/concepts/{concept}/cell.rb. end end # This is to autoload Operation::Dispatch, etc. I'm simply assuming people find this helpful in Rails. initializer "trailblazer.library_autoloading" do require "trailblazer/autoloading" end # thank you, http://stackoverflow.com/a/17573888/465070 initializer 'trailblazer.install', after: :load_config_initializers do |app| # the trb autoloading has to be run after initializers have been loaded, so we can tweak inclusion of features in # initializers. ActionDispatch::Reloader.to_prepare do Trailblazer::Railtie.autoload_operations(app) Trailblazer::Railtie.autoload_cells(app) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems