ruby - How do I override a class method through an instance_eval? -
I have a square Foo with a method bar.
How can I override the bar of FE with Foo.instance_eval? Def short #do some different end end
What to override:
Module ORM square foo def bar # some end and end
< Need to use / pre>
instance_eval
, works withclass_eval
overrides but do not have context
Assume that you want to change the module
so that whenever it is included, your new bar ()
will be used, you were very close:
Module ORM Square Foo Def Bar "Old Bar" and End and Larm :: FuClash_Avalde Bar is included in "New Bar" and Class. Lorem Foo.new.bar # = & gt; "New bar" end
Comments
Post a Comment