Class: Pageflow::Engine
- Inherits:
-
Rails::Engine
- Object
- Rails::Engine
- Pageflow::Engine
- Defined in:
- lib/pageflow/engine.rb
Overview
Rails integration
Instance Method Summary collapse
Instance Method Details
#eager_load! ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/pageflow/engine.rb', line 43 def eager_load! # Manually eager load `lib/pageflow` as the least bad option: # # - Autoload paths are not eager loaded in production. # # - `lib` cannot be an eager load path since otherwise templates # in `lib/generators` are also executed. # # - `lib/pageflow` cannot be an eager load path since eager load # paths are automatically used as autoload paths. That way # `lib/pageflow/admin/something.rb` could be autoloaded via # `Admin::Something`. # # - Using `require` in `lib/pageflow.rb` disables code # reloading. # # - Using `require_dependency` in `lib/pageflow.rb` does not # activate code reloading either since it requires the # autoload path to be set up correctly, which only happens # during initialization. super lib_path = config.root.join('lib') matcher = %r{\A#{Regexp.escape(lib_path.to_s)}/(.*)\.rb\Z} already_required_files = [ 'pageflow/engine', 'pageflow/global_config_api', 'pageflow/news_item_api', 'pageflow/version' ] Dir.glob("#{lib_path}/pageflow/**/*.rb").sort.each do |file| logical_path = file.sub(matcher, '\1') require_dependency(logical_path) unless already_required_files.include?(logical_path) end end |