class A
do_something_from_b
def method_in_a
end
end
module B
def self.included base
base.extend ClassMethods
end
module ClassMethods
def do_something_from_b
A.class_eval do
alias_method :aliased_method_in_a, :method_in_a
end
end
end
end
A.send(:include, B)
That code will fail because when do_somethind_from_b
gets called, method_in_a
doesn't exist yet.
So is there a way to hook into class A
after it has been fully loaded, without putting the do_something_from_b
call at the end of class A
?
Edit: As pointed out, there's other stuff wrong with the code, but that's beside the point. I just want to illustrate what I want to accomplish, which is run some code after a class is closed (it doesn't matter that it can be re-opened at will). And now I know that's probably not possible.
Thanks!