Class: ActiveAdmin::Reloader::RailsLessThan31Reloader
- Inherits:
-
AbstractReloader
- Object
- AbstractReloader
- ActiveAdmin::Reloader::RailsLessThan31Reloader
- Defined in:
- lib/active_admin/reloader.rb
Overview
Deals with reloading Active Admin on each request in development and once in production in Rails < 3.2.
Defined Under Namespace
Classes: FileUpdateChecker
Instance Attribute Summary collapse
-
#file_update_checker ⇒ Object
readonly
Returns the value of attribute file_update_checker.
Attributes inherited from AbstractReloader
#active_admin_app, #rails_app, #rails_version
Instance Method Summary collapse
-
#attach! ⇒ Object
Attach to Rails and perform the reload on each request.
-
#initialize(rails_app, active_admin_app, rails_version) ⇒ RailsLessThan31Reloader
constructor
A new instance of RailsLessThan31Reloader.
- #reload! ⇒ Object
- #reloader_class ⇒ Object
- #watched_paths ⇒ Object
Methods inherited from AbstractReloader
Constructor Details
#initialize(rails_app, active_admin_app, rails_version) ⇒ RailsLessThan31Reloader
Returns a new instance of RailsLessThan31Reloader.
89 90 91 92 93 94 |
# File 'lib/active_admin/reloader.rb', line 89 def initialize(rails_app, active_admin_app, rails_version) super @file_update_checker = FileUpdateChecker.new(watched_paths) do reload! end end |
Instance Attribute Details
#file_update_checker ⇒ Object (readonly)
Returns the value of attribute file_update_checker.
87 88 89 |
# File 'lib/active_admin/reloader.rb', line 87 def file_update_checker @file_update_checker end |
Instance Method Details
#attach! ⇒ Object
Attach to Rails and perform the reload on each request.
104 105 106 107 108 109 110 111 |
# File 'lib/active_admin/reloader.rb', line 104 def attach! # Bring the checker into local scope for the ruby block checker = file_update_checker reloader_class.to_prepare do checker.execute_if_updated end end |
#reload! ⇒ Object
96 97 98 99 100 |
# File 'lib/active_admin/reloader.rb', line 96 def reload! super file_update_checker.paths.clear watched_paths.each{|path| file_update_checker.paths << path } end |
#reloader_class ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/active_admin/reloader.rb', line 119 def reloader_class if major_rails_version == "3.1" ActionDispatch::Reloader else ActionDispatch::Callbacks end end |
#watched_paths ⇒ Object
113 114 115 116 117 |
# File 'lib/active_admin/reloader.rb', line 113 def watched_paths paths = active_admin_app.load_paths active_admin_app.load_paths.each{|path| paths += Dir[File.join(path, "**", "*.rb")]} paths end |