about summary refs log tree commit diff
path: root/config/initializers/reload_api.rb
blob: c6b599d802b633fe06ed4272040c553d93ab1e6c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
if Rails.env.development?
  ActiveSupport::Dependencies.explicitly_unloadable_constants << 'Twitter::API'

  api_files = Dir[Rails.root.join('app', 'api', '**', '*.rb')]

  api_reloader = ActiveSupport::FileUpdateChecker.new(api_files) do
    Rails.application.reload_routes!
  end

  ActionDispatch::Callbacks.to_prepare do
    api_reloader.execute_if_updated
  end
end