class A
def self.a
puts "self: #{self}; superclass: #{superclass}"
end
end
class B < A
class << self; undef_method(:a); end # I'm not allowed to use B.a
def self.b
# here I want to call A.a with B as self.
end
end
A.a #=> self: A; superclass: Object
B.b #=> self: B; superclass: A (expected)
I don’t want an alias_method solution. I’m looking for something like this.
UPDATE
The solution doesn’t need to be any similar to the link above; it’s only a suggestion. For example, I tried to do:
class B < A
def self.b
instance_eval(&A.method(:a).to_proc)
end
end
but this way I get an weird ArgumentError on Ruby 1.8.7.
Only solution here is to use
B.a.