time_constants
time_constants copied to clipboard
Use const_missing instead of defining every time constant manually.
You could use const_missing to dynamically return values for time constants, without having to manually define every single time constant. Additionally you could call const_set or memoize the values with a lazy Hash.
The whole point is to avoid methods.
If you use const_set with const_missing, const_missing will only be called once per time constant.