A quick tip to how to difine a class method as private method, I have seen lot of people doing it wrong way. Lets take a quick look on how to define a private instance method in ruby
In the above code, poop is a public method and bark is a private method. If you are calling a public method it will be something like:
But calling a private method will give you an error.
Now define private class method is not as it is for instance method. They don’t exists as normally as instance methods are there but still they exists.
if you want to define a class method private, lets try it the way instance method works,
Oops, private class method has been called :(. This is because the way ruby define the class methods, self is actually Dog and the private method scope was never considered, when ruby was defining this method as class method. Here are couple of ways you can define a class method as private.
Quick way and easiest way to define a class method as private.
2. class « self
Block of class methods 🙂