In Ruby:
module Example
class ExampleValidator
def mymethod
# do something important
end
end
end
Is it possible to make mymethod immutable (i.e. no monkey patching)?
Otherwise it would also be acceptable to "freeze" the entire class ExampleValidator.
Yes, you can call freeze on a Module.
Example::ExampleVaildator.freeze
However, I'd question why this is necessary. Perhaps it is solving a social problem with a technical one. A tool such as Rubocop should warn about monkey patches.