Skip to content

Commit

Permalink
Merge remote-tracking branch 't0m/master'
Browse files Browse the repository at this point in the history
Merge new changes from Tomas Doran's repo.
  • Loading branch information
rkitover committed Jan 8, 2014
2 parents c901ecb + 9dff510 commit ae73773
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
12 changes: 11 additions & 1 deletion Changes
Expand Up @@ -2,7 +2,17 @@ Revision history for CatalystX::Component::Traits

{{$NEXT}}
- convert to dzil
- replace Class::MOP::load_class with Class::Load::load_class

0.17 2014-01-02 13:32:00
- Fix RT#91014

0.16 2010-08-26 19:07:00
- Neglected to bump the version in last release.

0.15 2010-08-25 19:09:00
- Change excludes to -excludes when using MooseX::Traits::Pluggable
to avoid the deprecation warning.
- Change primary repository URI in metadata

0.14 2009-11-08 05:43:37
- minor code cleanup
Expand Down
12 changes: 3 additions & 9 deletions lib/CatalystX/Component/Traits.pm
Expand Up @@ -5,8 +5,8 @@ use Moose::Role;
use Carp;
use List::MoreUtils qw/firstidx any uniq/;
use Scalar::Util 'reftype';
use Class::Load ();
with 'MooseX::Traits::Pluggable' => { excludes => ['_find_trait'] };
use Class::Load qw/ load_first_existing_class /;
with 'MooseX::Traits::Pluggable' => { -excludes => ['_find_trait'] };

=head1 NAME
Expand Down Expand Up @@ -179,13 +179,7 @@ sub _merge_traits {
sub _find_trait {
my ($class, $base, $name) = @_;

my @tried; # FIXME - This sux, use load_first_existing_class ?
for my $trait ($class->_trait_search_order($base, $name)) {
push @tried, $trait;
return $trait if eval { Class::Load::load_class($trait) };
}

croak "Could not find a class for trait: $name (tried " . join(',', @tried) . ")";
load_first_existing_class($class->_trait_search_order($base, $name));
}

sub _trait_search_order {
Expand Down
4 changes: 2 additions & 2 deletions t/01-basic.t
Expand Up @@ -73,7 +73,7 @@ is eval { $instance->bar }, 'baz',
is $instance->find_app_class, 'MyApp', 'Can find app class passing instance';

is_deeply(
MyApp->controller('MyController')->_traits,
[qw/Foo Bar Quux/],
[MyApp->controller('MyController')->meta->calculate_all_roles]->[0]->name,
'Catalyst::TraitFor::Controller::SomeController::Foo|MyApp::TraitFor::Controller::SomeController::Bar|MyApp::TraitFor::Controller::SomeController::Quux',
'traits merged correctly'
);
4 changes: 2 additions & 2 deletions t/04-no_merge.t
Expand Up @@ -57,7 +57,7 @@ is eval { MyApp->controller('MyController')->bar }, 'baz',
'trait initialized from app config works';

is_deeply(
MyApp->controller('MyController')->_traits,
[qw/Foo Bar Baz/],
[MyApp->controller('MyController')->meta->calculate_all_roles]->[0]->name,
'Catalyst::TraitFor::Controller::SomeController::Foo|MyApp::TraitFor::Controller::SomeController::Bar|MyApp::TraitFor::Controller::SomeController::Baz',
'traits from app config override traits from component config'
);

0 comments on commit ae73773

Please sign in to comment.