Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • by tokuhirom (7396) on 2006.11.17 3:15 (#51695) Homepage Journal
    Index: lib/Sledge/Pages/Base.pm
    ====================================================== =============
    --- lib/Sledge/Pages/Base.pm    (revision 2)
    +++ lib/Sledge/Pages/Base.pm    (working copy)
    @@ -29,6 +29,7 @@

    use File::Spec;
    use URI;
    +use UNIVERSAL::require;

    use Sledge::Exceptions;
    use Sledge::FillInForm;
    @@ -238,6 +239,31 @@
         return $url;
    }

    +sub load_plugins {
    +    my ($class, @plugins) = @_;
    +
    +    for my $name (@plugins) {
    +        my $plugin = "Sledge::Plugin::$name";
    +        $plugin->require or croak $!;
    +
    +        unless ($plugin->can('add_methods') && $plugin->can('register_hooks')) {
    +            croak "$plugin is an old Sledge Plugin. use it directly";
    +        }
    +
    +        my @method_info = $plugin->add_methods;
    +        for (my $i = 0; $i < @method_info; $i += 2) {
    +            no strict 'refs';
    +            my $method_name = $method_info[$i];
    +            *{"$pkg\::$method_name"} = $method_info[$i + 1];
    +        }
    +
    +        my @hook_info = $plugin->resister_hooks;
    +        for (my $i = 0; $i < @hook_info; $i += 2) {
    +            $pkg->register_hook($hook_info[$i] => $hook_info[$i + 1])
    +        }
    +    }
    +}
    +
    sub _destroy_me {
         my $self = shift;
         # paranoia: guard against cyclic reference