Tuesday, June 12, 2012

[Rails] Grabbing all validation methods that run on a model

I am working on a project that will take custom validations on models
and translate them into javascript to be run on the client side. We
are currently passing in the model, and the validation method (as an
UnboundMethod ).

JStranslator(model, Validator.instance_method(:validate))

What I want is to get all the UnboundMethods that get used for
validating the model because our translator leverages the AST
representation of the methods (using 'live-ast'), therefore the
model_name.validators will not work (it returns an array I think). I
need to get all custom defined validation methods that are defined
inside the model itself as well as all validators the model uses.

One thought is to somehow use the callback chain, but I am unsure on
how to get the unboundmethods out of this.

Any help is much appreciated!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate