(A related, unanswered question: http://www.perlmonks.org/index.pl?node_id=234516).

I'm trying to utilize Class::MethodMaker for my open source shipping module (http://www.kavod.com/Business-Shipping), but currently, none of the MethodMaker-generated methods call SUPER. So, extended MethodMaker with a subclass that does, but that results in this error:

Can't locate auto/CustomMethodMaker/SUPER/required.al in @INC

(Where $method_name happened to be "required" at the time). My pet theory is that SUPER only works within the context of the correct package, and MethodMaker isn't it. I've tried to reduce all of the code down to the simplest example possible that still exhibits the problem, and pasted it below.

My questions are:

I would greatly appreciate any comments. Cheers,

-- Dan Browning, Kavod Technologies, <db@kavod.com> 360.843.4074x217 6700 NE 162nd Ave, Ste 611-210, Vancouver, WA. Random Fortune: Consultant, n.: An ordinary man a long way from home.
###################################################################### ## CustomMethodMaker ## (must be in it's own file, due to the fact that ## it has to be 'used'. ###################################################################### package CustomMethodMaker; use base ( 'Class::MethodMaker' ); =head2 grouped_fields_inherit Works like grouped_fields, except that it also calls the parent class. =cut sub grouped_fields_inherit { my ($class, %args) = @_; my %methods; foreach (keys %args) { my @slots = @{$args{$_}}; $class->get_set(@slots); my $method_name = $_; $methods{$_} = sub { my ( $self ) = @_; my @parent_slots = (); my $to_execute = "SUPER::$method_name"; # # The following line causes this error: # #Can't locate auto/CustomMethodMaker/SUPER/<METHOD>.al in @INC # @parent_slots = $self->$to_execute(); return ( @parent_slots, @slots ); }; } $class->install_methods(%methods); } 1; #!/usr/bin/perl use strict; use warnings; # See CustomMethodMaker.pm ###################################################################### ## Bug ###################################################################### package Bug; use Class::MethodMaker new_hash_init => 'new', grouped_fields => [ 'required' => [ 'id', 'type', 'description' ], 'optional' => [ 'severity' ], ]; ###################################################################### ## FixedBug ###################################################################### package FixedBug; use base ( 'Bug' ); use CustomMethodMaker new_hash_init => 'new', grouped_fields_inherit => [ 'required' => [ 'date_fixed', 'repairer' ], 'optional' => [ 'repair_notes', 'patch_file' ], ]; ###################################################################### ## Main ###################################################################### package Main; my $bug = Bug->new(); print join( ', ', $bug->required() ) . "\n"; # # Prints 'id', 'type', 'description' # my $fixed_bug = FixedBug->new(); print join( ', ', $fixed_bug->required() ) . "\n"; # # Prints 'date_fixed', 'repairer' -- but I want it to print: # 'id', 'type', 'description', 'date_fixed', 'repairer' #

In reply to Calling SUPER in MethodMaker-generated methods by danb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.