How to lock a ruby definition?

def self.def1
end

how to lock a ruby definition to use it one instance at a time?

You create “singleton methods” (don’t confuse this with Java/GoF
“singletons”):

x = []
y = []
def x.sayHello; puts “Hello world!” end

x.sayHello
y.sayHello # NoMethodError