Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Use const_missing instead of defining every time constant manually. #1

Open
postmodern opened this Issue Feb 22, 2012 · 2 comments

Comments

Projects
None yet
2 participants

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment