Class: ActiveAdmin::Reloader
- Inherits:
-
Object
- Object
- ActiveAdmin::Reloader
- Defined in:
- lib/active_admin/reloader.rb
Overview
Deals with reloading Active Admin on each request in development and once in production.
Instance Attribute Summary collapse
-
#active_admin_app ⇒ Object
readonly
Returns the value of attribute active_admin_app.
-
#file_update_checker ⇒ Object
readonly
Returns the value of attribute file_update_checker.
-
#rails_app ⇒ Object
readonly
Returns the value of attribute rails_app.
Instance Method Summary collapse
-
#attach! ⇒ Object
Attach to Rails and perform the reload on each request.
-
#initialize(rails_app, active_admin_app, rails_version) ⇒ Reloader
constructor
A new instance of Reloader.
- #reload! ⇒ Object
- #reloader_class ⇒ Object
- #watched_paths ⇒ Object
Constructor Details
#initialize(rails_app, active_admin_app, rails_version) ⇒ Reloader
Returns a new instance of Reloader.
23 24 25 26 27 28 29 30 |
# File 'lib/active_admin/reloader.rb', line 23 def initialize(rails_app, active_admin_app, rails_version) @rails_app = rails_app @active_admin_app = active_admin_app @rails_version = rails_version.to_s @file_update_checker = FileUpdateChecker.new(watched_paths) do reload! end end |
Instance Attribute Details
#active_admin_app ⇒ Object (readonly)
Returns the value of attribute active_admin_app.
16 17 18 |
# File 'lib/active_admin/reloader.rb', line 16 def active_admin_app @active_admin_app end |
#file_update_checker ⇒ Object (readonly)
Returns the value of attribute file_update_checker.
16 17 18 |
# File 'lib/active_admin/reloader.rb', line 16 def file_update_checker @file_update_checker end |
#rails_app ⇒ Object (readonly)
Returns the value of attribute rails_app.
16 17 18 |
# File 'lib/active_admin/reloader.rb', line 16 def rails_app @rails_app end |
Instance Method Details
#attach! ⇒ Object
Attach to Rails and perform the reload on each request.
40 41 42 43 44 45 46 47 |
# File 'lib/active_admin/reloader.rb', line 40 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
32 33 34 35 36 37 |
# File 'lib/active_admin/reloader.rb', line 32 def reload! active_admin_app.unload! rails_app.reload_routes! file_update_checker.paths.clear watched_paths.each{|path| file_update_checker.paths << path } end |
#reloader_class ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/active_admin/reloader.rb', line 55 def reloader_class if @rails_version[0..2] == '3.1' ActionDispatch::Reloader else ActionDispatch::Callbacks end end |
#watched_paths ⇒ Object
49 50 51 52 53 |
# File 'lib/active_admin/reloader.rb', line 49 def watched_paths paths = active_admin_app.load_paths active_admin_app.load_paths.each{|path| paths += Dir[File.join(path, "**", "*.rb")]} paths end |