First page Back Continue Last page Overview Text


Note that method_missing is not used here. Because we know in advance which validation methods exist, we only create methods for those validations.

In this particular case, the methods also have different arity, so two separate class evals are used, one for methods that accept an additional argument, and one for methods that do not.

In both cases, the methods created via metaprogramming just call the appropriate validation method on the object for the given attribute.