From: Jesse Luehrs Date: Fri, 26 Jun 2009 15:03:37 +0000 (-0500) Subject: move _caller_info into Moose::Util X-Git-Tag: 0.84~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=833b56a7664341058563196cd7fee82a5a526e50;p=gitmo%2FMoose.git move _caller_info into Moose::Util --- diff --git a/lib/Moose.pm b/lib/Moose.pm index 51a0a7c..859bc9a 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -32,13 +32,6 @@ use Moose::Meta::Role::Application::ToInstance; use Moose::Util::TypeConstraints; use Moose::Util (); -sub _caller_info { - my $level = @_ ? ($_[0] + 1) : 2; - my %info; - @info{qw(package file line)} = caller($level); - return \%info; -} - sub throw_error { # FIXME This shift; @@ -68,7 +61,7 @@ sub has { Moose->throw_error('Usage: has \'name\' => ( key => value, ... )') if @_ % 2 == 1; - my %options = ( definition_context => _caller_info(), @_ ); + my %options = ( definition_context => Moose::Util::_caller_info(), @_ ); my $attrs = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ]; Class::MOP::Class->initialize($class)->add_attribute( $_, %options ) for @$attrs; } diff --git a/lib/Moose/Role.pm b/lib/Moose/Role.pm index d042ae4..ec18aa7 100644 --- a/lib/Moose/Role.pm +++ b/lib/Moose/Role.pm @@ -41,7 +41,7 @@ sub has { my $meta = Moose::Meta::Role->initialize(shift); my $name = shift; croak 'Usage: has \'name\' => ( key => value, ... )' if @_ == 1; - my %options = ( definition_context => Moose::_caller_info(), @_ ); + my %options = ( definition_context => Moose::Util::_caller_info(), @_ ); my $attrs = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ]; $meta->add_attribute( $_, %options ) for @$attrs; } diff --git a/lib/Moose/Util.pm b/lib/Moose/Util.pm index d4c0d93..cfa8b2d 100644 --- a/lib/Moose/Util.pm +++ b/lib/Moose/Util.pm @@ -207,6 +207,13 @@ sub english_list { return $list; } +sub _caller_info { + my $level = @_ ? ($_[0] + 1) : 2; + my %info; + @info{qw(package file line)} = caller($level); + return \%info; +} + 1; __END__