Sha256: 79e328db55a208bbfe18cab8f5b72d53c59a24731286facbf65c355fdba37110

Contents?: true

Size: 752 Bytes

Versions: 4

Compression:

Stored size: 752 Bytes

Contents

module ActiveAdmin
  # Deals with reloading Active Admin on each request in 
  # development and once in production.
  class Reloader

    # @param [String] rails_version
    #   The version of Rails we're using. We use this to switch between
    #   the correcr Rails reloader class.
    def initialize(rails_version)
      @rails_version = rails_version.to_s
    end

    # Attach to Rails and perform the reload on each request.
    def attach!
      reloader_class.to_prepare do
        ActiveAdmin.application.unload!
        Rails.application.reload_routes!
      end
    end

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

  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
activeadmin-0.3.2 lib/active_admin/reloader.rb
activeadmin-0.3.1 lib/active_admin/reloader.rb
activeadmin-0.3.0 lib/active_admin/reloader.rb
nsm-activeadmin-0.2.2 lib/active_admin/reloader.rb