Class: Rails::Application::RoutesReloader
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: | Object |
Defined in: | railties/lib/rails/application/routes_reloader.rb |
Constant Summary
::ActiveSupport::Callbacks
- Included
::ActiveSupport::Callbacks
- Attributes & Methods
- .__callbacks rw
- #__callbacks readonly
Class Method Summary
- .new ⇒ RoutesReloader constructor
::ActiveSupport::DescendantsTracker
- self
Instance Attribute Summary
- #eager_load rw
- #execute_if_updated readonly
- #external_routes readonly
- #loaded readonly
- #paths readonly
- #route_sets readonly
- #run_after_load_paths rw private
- #run_after_load_paths=(value) rw Internal use only
Instance Method Summary
- #execute
- #execute_unless_loaded
- #reload!
- #updated? ⇒ Boolean
- #clear! private
- #finalize! private
- #load_paths private
- #revert private
- #updater private
::ActiveSupport::Callbacks
- Included
#run_callbacks | Runs the callbacks for the given event. |
#halted_callback_hook | A hook invoked every time a before callback is halted. |
Constructor Details
.new ⇒ RoutesReloader
# File 'railties/lib/rails/application/routes_reloader.rb', line 15
def initialize @paths = [] @route_sets = [] @external_routes = [] @eager_load = false @loaded = false end
Class Attribute Details
.__callbacks (rw)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 69
class_attribute :__callbacks, instance_writer: false, instance_predicate: false, default: {}
Instance Attribute Details
#__callbacks (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 69
class_attribute :__callbacks, instance_writer: false, instance_predicate: false, default: {}
#eager_load (rw)
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 11
attr_accessor :eager_load
#execute_if_updated (readonly)
[ GitHub ]#external_routes (readonly)
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 10
attr_reader :route_sets, :paths, :external_routes, :loaded
#loaded (readonly)
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 10
attr_reader :route_sets, :paths, :external_routes, :loaded
#paths (readonly)
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 10
attr_reader :route_sets, :paths, :external_routes, :loaded
#route_sets (readonly)
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 10
attr_reader :route_sets, :paths, :external_routes, :loaded
#run_after_load_paths (rw, private)
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 68
def run_after_load_paths @run_after_load_paths ||= -> { } end
#run_after_load_paths=(value) (rw)
This method is for internal use only.
[ GitHub ]
# File 'railties/lib/rails/application/routes_reloader.rb', line 12
attr_writer :run_after_load_paths # :nodoc:
Instance Method Details
#clear! (private)
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 56
def clear! route_sets.each do |routes| routes.disable_clear_and_finalize = true routes.clear! end end
#execute
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 32
def execute @loaded = true updater.execute end
#execute_unless_loaded
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 37
def execute_unless_loaded unless @loaded execute ActiveSupport.run_load_hooks(:after_routes_loaded, Rails.application) true end end
#finalize! (private)
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 72
def finalize! route_sets.each(&:finalize!) end
#load_paths (private)
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 63
def load_paths paths.each { |path| load(path) } run_after_load_paths.call end
#reload!
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 23
def reload! clear! load_paths finalize! route_sets.each(&:eager_load!) if eager_load ensure revert end
#revert (private)
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 76
def revert route_sets.each do |routes| routes.disable_clear_and_finalize = false end end
#updated? ⇒ Boolean
# File 'railties/lib/rails/application/routes_reloader.rb', line 13
delegate :execute_if_updated, :updated?, to: :updater
#updater (private)
[ GitHub ]# File 'railties/lib/rails/application/routes_reloader.rb', line 46
def updater @updater ||= begin dirs = @external_routes.each_with_object({}) do |dir, hash| hash[dir.to_s] = %w(rb) end ActiveSupport::FileUpdateChecker.new(paths, dirs) { reload! } end end