class ActiveAdmin::Reloader
development and once in production.
Deals with reloading Active Admin on each request in
def attach!
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
def initialize(rails_app, active_admin_app, rails_version)
-
rails_version
(String
) -- The version of Rails we're using. -
app
(ActiveAdmin::Application
) --
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
def reload!
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
def reloader_class
def reloader_class if @rails_version[0..2] == '3.1' ActionDispatch::Reloader else ActionDispatch::Callbacks end end
def watched_paths
def watched_paths paths = active_admin_app.load_paths active_admin_app.load_paths.each{|path| paths += Dir[File.join(path, "**", "*.rb")]} paths end