I have a class Initialization.
I have a method send_mail which is a class method
def self.send_mail
a = user_stats
end
user_stats is a private method and when I try to call this method, it throws an error
class << self
private
def user_stats
true
end
end
When I tried accessing user_stats ,
undefined method 'user_stats' for Initialization
Also tried
class << self
def self.send_mail
a = user_stats
end
private
def user_stats
true
end
end
Both of your approaches are correct, but in the latter you shouldn't use
self
, cause you already define method inInitialization
's eigenclass:Your first approach also works for me: