Class-Autouse

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
      print Foo::Wrapper->class_method,"\n";
 
sugar
  This method is provided to support "syntactic sugar": allowing the
  developer to put things into Perl which do not look like regular Perl.
  There are several ways to do this in Perl. Strategies which require
  overriding UNIVERSAL::AUTOLOAD can use this interface instead to share
  that method with the superloader, and with class gnerators.
 
  When Perl is unable to find a subroutine/method, and all of the class
  loaders are exhausted, callbacks registered via sugar() are called. The
  callbacks recieve the class name, method name, and parameters of the
  call.
 
  If the callback returns nothing, Class::Autouse will continue to iterate
  through other callbacks. The first callback which returns a true value
  will end iteration. That value is expected to be a CODE reference which
  will respond to the AUTOLOAD call.
 
  Note: The sugar callback(s) will only be fired by UNIVERSAL::AUTOLOAD
  after all other attempts at loading the class are done, and after
  attempts to use regular AUTOLOAD to handle the method call. It is never
  fired by isa() or can(). It will fire repatedly for the same class. To
  generate classes, use the regular CODE ref support in autouse().
 
 Syntactic Sugar Example

lib/Class/Autouse.pm  view on Meta::CPAN

502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
                        }
                }
        }
 
        return 1;
}
 
sub _try_loaders {
        _debug(\@_, 0) if DEBUG;
        my ($class, $function, @optional_args) = @_;
        # The function and args are only present to help callbacks whose main goal is to
        # do "syntactic sugar" instead of really writing a class
 
        # This allows us to shortcut out of re-checking a class
        $TRIED_CLASS{$class}++;
 
        if ( _namespace_occupied($class) ) {
                $LOADED{$class} = 1;
                _load_ancestors($class);
                return 1;
        }

lib/Class/Autouse.pm  view on Meta::CPAN

1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
=head2 sugar
 
This method is provided to support "syntactic sugar": allowing the developer
to put things into Perl which do not look like regular Perl.  There are
several ways to do this in Perl.  Strategies which require overriding
UNIVERSAL::AUTOLOAD can use this interface instead to share that method
with the superloader, and with class gnerators.
 
When Perl is unable to find a subroutine/method, and all of the class loaders
are exhausted, callbacks registered via sugar() are called.  The callbacks
recieve the class name, method name, and parameters of the call.
 
If the callback returns nothing, Class::Autouse will continue to iterate through
other callbacks.  The first callback which returns a true value will
end iteration.  That value is expected to be a CODE reference which will respond
to the AUTOLOAD call.
 
Note: The sugar callback(s) will only be fired by UNIVERSAL::AUTOLOAD after all
other attempts at loading the class are done, and after attempts to use regular
AUTOLOAD to handle the method call.  It is never fired by isa() or can().  It
will fire repatedly for the same class.  To generate classes, use the
regular CODE ref support in autouse().
 
=head3 Syntactic Sugar Example



( run in 0.478 second using v1.01-cache-2.11-cpan-5f2e87ce722 )