K
Kevin Barnes
I am trying to hide a method in a subclass whose base class has
method_missing defined.
class Base
def method_missing(method, *args)
puts "#{method} caught in base"
end
end
class Sub < Base
def see_me
puts 'hi'
end
def no_see
puts 'hidden'
end
private :no_see
end
s = Sub.new
s.see_me
s.no_see
Of course, the method isn't really hidden/private anymore. I know one
way to solve this with method_missing in Sub and querying
private_methods.include? Is there a better way?
Cheers,
Kevin
method_missing defined.
class Base
def method_missing(method, *args)
puts "#{method} caught in base"
end
end
class Sub < Base
def see_me
puts 'hi'
end
def no_see
puts 'hidden'
end
private :no_see
end
s = Sub.new
s.see_me
s.no_see
Of course, the method isn't really hidden/private anymore. I know one
way to solve this with method_missing in Sub and querying
private_methods.include? Is there a better way?
Cheers,
Kevin