Skip to content

Commit

Permalink
Start tracking applied traits.
Browse files Browse the repository at this point in the history
  • Loading branch information
genehack committed Apr 14, 2011
1 parent 2b64268 commit aaad9b6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/MooseX/amine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ sub _extract_attribute_metainfo {
$return->{meta}{constraint} = $meta_attr->type_constraint->name
if ( $meta_attr->has_type_constraint );

$return->{meta}{traits} = $meta_attr->applied_traits
if ( $meta_attr->has_applied_traits );

foreach ( qw/
is_weak_ref is_required is_lazy is_lazy_build should_coerce
should_auto_deref has_trigger has_handles
Expand Down
8 changes: 8 additions & 0 deletions t/01-basic-object.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ my $expected_data_structure = {
reader => 'bare_ro_attribute',
from => 'Test::Basic::Object',
} ,
hash_trait => {
accessor => 'hash_trait',
from => 'Test::Basic::Object',
meta => {
constraint => 'HashRef' ,
traits => [ 'Moose::Meta::Attribute::Native::Trait::Hash' ] ,
},
},
},
methods => {
simple_method => {
Expand Down
13 changes: 11 additions & 2 deletions t/05-basic-object-include-all.t
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ my $expected_data_structure = {
reader => 'bare_ro_attribute',
from => 'Test::Basic::Object',
} ,
hash_trait => {
accessor => 'hash_trait',
from => 'Test::Basic::Object',
meta => {
constraint => 'HashRef' ,
traits => [ 'Moose::Meta::Attribute::Native::Trait::Hash' ] ,
},
},
_private_attribute => {
reader => '_private_attribute' ,
from => 'Test::Basic::Object' ,
Expand All @@ -40,8 +48,9 @@ my $expected_data_structure = {
methods => {
_private_attribute => { from => 'Test::Basic::Object' } ,
_private_method => { from => 'Test::Basic::Object' } ,
simple_attribute => { from => 'Test::Basic::Object' },
bare_ro_attribute => { from => 'Test::Basic::Object' },
simple_attribute => { from => 'Test::Basic::Object' } ,
bare_ro_attribute => { from => 'Test::Basic::Object' } ,
hash_trait => { from => 'Test::Basic::Object' } ,
simple_method => { from => 'Test::Basic::Object' } ,
BUILDALL => { from => 'Moose::Object' },
BUILDARGS => { from => 'Moose::Object' },
Expand Down
8 changes: 8 additions & 0 deletions t/06-basic-object-by-path.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ my $expected_data_structure = {
reader => 'bare_ro_attribute',
from => 'Test::Basic::Object',
} ,
hash_trait => {
accessor => 'hash_trait',
from => 'Test::Basic::Object',
meta => {
constraint => 'HashRef' ,
traits => [ 'Moose::Meta::Attribute::Native::Trait::Hash' ] ,
},
},
},
methods => {
simple_method => {
Expand Down
1 change: 1 addition & 0 deletions t/lib/Test/Basic/Object.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package Test::Basic::Object;
use Moose;
has 'simple_attribute' => ( is => 'rw' , isa => 'Str' );
has 'bare_ro_attribute' => ( is => 'ro' );
has 'hash_trait' => ( is => 'rw' , traits => [ qw/ Hash / ] );
has '_private_attribute' => ( is => 'ro' , isa => 'Int' );
sub simple_method { return 'simple' }
sub _private_method { return 'private' }
Expand Down

0 comments on commit aaad9b6

Please sign in to comment.