Sunday 15 January 2012

inheritance - List of defined super methods for a certain class method in ruby -


I am working on a system with some complex class / mix hierarchy. There are several layers scattered in many different files, so I want to quickly see that a super call series is for the given method. For example

  "AAA" + Super () End and module for module AAA DF BBB DRT tos "BBB" + Super () End and Class MyEre End Lt; Array includes AAA BBB def to_s "MyArray" + super () End End & gt; MyArray.new.to_s = & gt; "MyEre BBB AAA []" & gt; Method_supers (MyEre ,: to_s) = & gt; ["MyArray # to_s", "BBB # to_s", "AAA # to_s", "Array # to_s", ...]    

maybe something like this? Class A Def FU; P: A; End end module b def foo; P: B; Super; End and module c; And Class D & LT; One included in B, C DEF foo; P: D; Super; End and PD Distansors Keep_if {| C | C.instance_methods.include? : Foo} # [D, B, A]

If it looks correct, then you can modify this function accordingly:

  def Object. Super_methods (method) ancestors. Keep_if {| C | C.instance_methods.include? Method} and PD Super_ithms (: Foo) # [D, B, A]    

No comments:

Post a Comment