From: Matt S Trout Date: Fri, 4 Dec 2009 14:03:56 +0000 (+0000) Subject: slightly more convenience X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5ed50637a6a3590982b86580bef646f2d8b44b13;p=gitmo%2FMooseX-Antlers.git slightly more convenience --- diff --git a/lib/MooseX/Antlers/EvalTracker.pm b/lib/MooseX/Antlers/EvalTracker.pm index 1f5daf4..8466698 100644 --- a/lib/MooseX/Antlers/EvalTracker.pm +++ b/lib/MooseX/Antlers/EvalTracker.pm @@ -41,7 +41,7 @@ sub enable { return if $self->is_enabled; $self->_install('our'); $self->is_enabled(1); - return; + return $self; } sub disable { @@ -49,7 +49,7 @@ sub disable { return unless $self->is_enabled; $self->_install('original'); $self->is_enabled(0); - return; + return $self; } sub _install { diff --git a/lib/MooseX/Antlers/RefTracker.pm b/lib/MooseX/Antlers/RefTracker.pm index 26473c1..d53fe66 100644 --- a/lib/MooseX/Antlers/RefTracker.pm +++ b/lib/MooseX/Antlers/RefTracker.pm @@ -13,6 +13,13 @@ with 'MooseX::Antlers::Visitor::NameTracking'; has '_traced_refs' => (is => 'ro', lazy => 1, default => sub { {} }); has '_traced_names' => (is => 'ro', lazy => 1, default => sub { {} }); +sub trace_refs { + my ($class, $name, $refs) = @_; + my $self = $class->new({ root_name => $name }); + $self->visit($refs); + return $self->traced_ref_map; +} + before visit_ref => sub { my ($self, $data) = @_;