diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-12-19 14:19:23 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-12-19 14:19:23 -0600 |
commit | dbe4c918ce9e4678550c0704310d582889196f7d (patch) | |
tree | 9ea0e9b4439d16d5bd31e86f077e7161da14bf03 | |
parent | 129e7fac6fc245bf498a8bbea34a74edb2147784 (diff) | |
download | moosex-module-refresh-dbe4c918ce9e4678550c0704310d582889196f7d.tar.gz moosex-module-refresh-dbe4c918ce9e4678550c0704310d582889196f7d.zip |
some more docs and todo comments
-rw-r--r-- | lib/MooseX/Module/Refresh.pm | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/MooseX/Module/Refresh.pm b/lib/MooseX/Module/Refresh.pm index d8a77a5..9831cd6 100644 --- a/lib/MooseX/Module/Refresh.pm +++ b/lib/MooseX/Module/Refresh.pm @@ -5,10 +5,19 @@ extends 'Module::Refresh'; =head1 NAME -MooseX::Module::Refresh - +MooseX::Module::Refresh - Module::Refresh for Moose classes =head1 SYNOPSIS + # During each request, call this once to refresh changed modules: + + MooseX::Module::Refresh->refresh; + + # Each night at midnight, you automatically download the latest + # Acme::Current from CPAN. Use this snippet to make your running + # program pick it up off disk: + + $refresher->refresh_module('Acme/Current.pm'); =head1 DESCRIPTION @@ -18,6 +27,7 @@ MooseX::Module::Refresh - sub _pm_file_to_mod { my ($file) = @_; $file =~ s{\.pm$}{}; + # XXX: is this correct on windows? $file =~ s{/}{::}g; return $file; } @@ -29,12 +39,17 @@ after unload_module => sub { return unless defined $meta; return unless $meta->isa('Moose::Meta::Class'); if ($meta->is_immutable) { + # XXX: we can probably do better here, if we try hard enough - would + # require walking the entire inheritance tree downwards though warn "Can't modify an immutable class"; return; } $self->unload_methods($meta); $self->unload_attrs($meta); - # XXX: this is probably wrong, but... + # XXX: this is probably wrong, but necessary for now, since the metaclass + # still existing means that Moose::init_meta won't set the default base + # class. this will break things that try to "use base" something before + # doing "use Moose", not sure how to get around that. $meta->superclasses('Moose::Object'); bless $meta, 'Moose::Meta::Class'; # XXX: why is this breaking @@ -47,6 +62,7 @@ sub unload_methods { my $self = shift; my ($meta) = @_; for my $meth ($meta->get_method_list) { + # don't remove things that unload_subs didn't remove $meta->remove_method($meth) unless exists $DB::sub{$meta->name . "::$meth"}; } |