You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document how to check whether Spring is running from within your code
You can check whether Spring is running by checking whether the
`Spring` constant is defined.
```ruby
if defined?(Spring)
# This code will only run if Spring is running.
end
```
This is the approach taken by Spring binary, [`bin/spring`][1].
I've often personally wanted to check whether Spring is running
(e.g. when I've been seeing strange behaviour that I suspect is
related to class reloading), and this is potentially useful for
other gems too (e.g. to warn if environment variables might not
be reflected as expected due to running through the Spring
preloader).
[1]: https://github.com/rails/spring/blob/master/bin/spring#L3
0 commit comments