class Foo
@@first_time = true
def self.private_bar
if @@first_time
puts "Hi"
else
puts "Oi, you don't work here"
end
@@first_time = false
end
private_class_method :private_bar
public
def calling_private_method
self.class.send :private_bar
another_private_bar
end
end
f=Foo.new
f.calling_private_method
f.class.send :private_bar
The output should be something like this:
Hi
NoMethodError: private method `private_bar'
However, the output is:
Hi
Oi, you don't work
Why is this happening? This must be a bug otherwise it is an important violation of the encapsulation of information, right?