banister / method_source

return the sourcecode for a method
MIT License
361 stars 43 forks source link

Add MethodSource.clear_cache #73

Closed yhirano55 closed 3 years ago

yhirano55 commented 3 years ago

We often need to clear cache.

For example, in web application development, when we changed source code, we would like the change applied to the app server without reboot.

In the case of a Rails application, this requires the following configuration:

Rails.application.configure do
  config.to_prepare do
    MethodSource.instance_variable_set(:@lines_for_file, {})
  end
end

It seems so ugly, isn't it? So I feel we need to add MethodSource.clear_cache interface.

  Rails.application.configure do
    config.to_prepare do
-     MethodSource.instance_variable_set(:@lines_for_file, {})
+     MethodSource.clear_cache
    end
  end
banister commented 3 years ago

LGTM 🚢

awfulcooking commented 2 years ago

\o/ please release this