Is there a way to avoid (raise an error when it is attempted) definition of a method with a certain name, for example Foo#bar
? (A usecase would be when Foo#bar
is already defined, and I want to avoid that method being overridden, but that is irrelevant to the question.) I am assuming something like:
class Foo
prohibit_definition :bar
end
...
# Later in some code
class Foo
def bar
...
end
end
# => Error: `Foo#bar' cannot be defined