Class: ApiMaker::RoutesFileReloader

Inherits:
ApplicationService show all
Defined in:
app/services/api_maker/routes_file_reloader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationService

#api_maker_json

Constructor Details

#initialize(file_paths:) ⇒ RoutesFileReloader

Returns a new instance of RoutesFileReloader.



4
5
6
# File 'app/services/api_maker/routes_file_reloader.rb', line 4

def initialize(file_paths:)
  @file_paths = file_paths
end

Instance Attribute Details

#file_pathsObject (readonly)

Returns the value of attribute file_paths.



2
3
4
# File 'app/services/api_maker/routes_file_reloader.rb', line 2

def file_paths
  @file_paths
end

Instance Method Details

#performObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/services/api_maker/routes_file_reloader.rb', line 8

def perform
  reloader = Rails.application.config.file_watcher.new(file_paths) do
    Rails.application.reload_routes!
  end

  Rails.application.reloaders << reloader
  Rails.application.reloader.to_run do
    reloader.execute_if_updated
  end

  succeed!
end