my ruby (on rails) class looks like:
class Foo def self.method1 someAction end
def self.method2 someAction end
def someAction //doSmth end end
any ideas how to make this work or achieve the same behavior some other way?
thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If some_action is appropriate as a class method, I’d do it like this:
If method1 is supposed to be a convenience method, then I’d do like Hates_ said to.
The decision for me is usually whether some_action is more of a utility method (like generating a random key, in which case I’d pick the first form), or if it’s an entry point to something more complex (like a parser, in which case I’d pick the second form).