I have a module RegexHelper which contain methoids to verify if a string is only numeric:
module RegexHelper
def is_numeric?(str)
!!str.match(/^[0-9]+$/)
end
end
And I include this module in several classes and it works well when I try using them in instance methods. But now I want to use them in class methods and it simply doesnt work eaven callingRegexHelper.is_numeric?(my_str) doesnt work for me.
I think the problem might be that the include RegeHelper is exexute when creating a new object. So how can I make this work for the whole class?
Try this:
includeis for adding instance methods to a class andextendis for adding class methods.