Class: RoutesLazyRoutes::RoutesReloaderWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/routes_lazy_routes/routes_reloader_wrapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(original_routes_reloader) ⇒ RoutesReloaderWrapper

Returns a new instance of RoutesReloaderWrapper.



13
14
15
16
# File 'lib/routes_lazy_routes/routes_reloader_wrapper.rb', line 13

def initialize(original_routes_reloader)
  @original_routes_reloader = original_routes_reloader
  @mutex = Mutex.new
end

Instance Method Details

#executeObject



18
19
20
# File 'lib/routes_lazy_routes/routes_reloader_wrapper.rb', line 18

def execute
  # pretty vacant
end

#reload!Object



22
23
24
25
26
27
28
29
# File 'lib/routes_lazy_routes/routes_reloader_wrapper.rb', line 22

def reload!
  @mutex.synchronize do
    if Rails.application.routes_reloader == self
      Rails.application.instance_variable_set :@routes_reloader, @original_routes_reloader
      @original_routes_reloader.execute
    end
  end
end