Class: ActiveAdmin::Reloader

Inherits:
Object
  • Object
show all
Defined in:
lib/active_admin/reloader.rb

Overview

Deals with reloading Active Admin on each request in development and once in production.

Instance Method Summary collapse

Constructor Details

#initialize(rails_version) ⇒ Reloader

Returns a new instance of Reloader.

Parameters:

  • rails_version (String)

    The version of Rails we’re using. We use this to switch between the correcr Rails reloader class.



9
10
11
# File 'lib/active_admin/reloader.rb', line 9

def initialize(rails_version)
  @rails_version = rails_version.to_s
end

Instance Method Details

#attach!Object

Attach to Rails and perform the reload on each request.



14
15
16
17
18
19
# File 'lib/active_admin/reloader.rb', line 14

def attach!
  reloader_class.to_prepare do
    ActiveAdmin.application.unload!
    Rails.application.reload_routes!
  end
end

#reloader_classObject



21
22
23
24
25
26
27
# File 'lib/active_admin/reloader.rb', line 21

def reloader_class
  if @rails_version[0..2] == '3.1'
    ActionDispatch::Reloader
  else
    ActionDispatch::Callbacks
  end
end