From: Jesse Luehrs Date: Fri, 10 Jul 2009 02:08:48 +0000 (-0500) Subject: merge List into Array and ImmutableHash into Hash X-Git-Tag: 0.89_02~88 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e11fb12c52178ccb80cf11eafc163c0db3eeaef9;p=gitmo%2FMoose.git merge List into Array and ImmutableHash into Hash --- diff --git a/lib/Moose/AttributeHelpers.pm b/lib/Moose/AttributeHelpers.pm index 1e7d6b3..7301167 100644 --- a/lib/Moose/AttributeHelpers.pm +++ b/lib/Moose/AttributeHelpers.pm @@ -11,10 +11,8 @@ use Moose::Meta::Attribute::Trait::Native::Bool; use Moose::Meta::Attribute::Trait::Native::Counter; use Moose::Meta::Attribute::Trait::Native::Number; use Moose::Meta::Attribute::Trait::Native::String; -use Moose::Meta::Attribute::Trait::Native::List; use Moose::Meta::Attribute::Trait::Native::Array; use Moose::Meta::Attribute::Trait::Native::Hash; -use Moose::Meta::Attribute::Trait::Native::ImmutableHash; 1; diff --git a/lib/Moose/Meta/Attribute/Trait/Native/ImmutableHash.pm b/lib/Moose/Meta/Attribute/Trait/Native/ImmutableHash.pm deleted file mode 100644 index 9f35512..0000000 --- a/lib/Moose/Meta/Attribute/Trait/Native/ImmutableHash.pm +++ /dev/null @@ -1,96 +0,0 @@ - -package Moose::Meta::Attribute::Trait::Native::ImmutableHash; -use Moose::Role; - -our $VERSION = '0.87'; -$VERSION = eval $VERSION; -our $AUTHORITY = 'cpan:STEVAN'; - -use Moose::Meta::Attribute::Trait::Native::MethodProvider::ImmutableHash; - -with 'Moose::Meta::Attribute::Trait::Native::Collection'; - -has 'method_provider' => ( - is => 'ro', - isa => 'ClassName', - predicate => 'has_method_provider', - default => 'Moose::Meta::Attribute::Trait::Native::MethodProvider::ImmutableHash' -); - -sub _helper_type { 'HashRef' } - -no Moose::Role; - -package # hide me from search.cpan.org - Moose::Meta::Attribute::Custom::Trait::ImmutableHash; -sub register_implementation { - 'Moose::Meta::Attribute::Trait::Native::ImmutableHash' -} - - -1; - -__END__ - -=pod - -=head1 NAME - -Moose::Meta::Attribute::Trait::Native::ImmutableHash - -=head1 SYNOPSIS - - package Stuff; - use Moose; - use Moose::AttributeHelpers; - - has 'options' => ( - metaclass => 'ImmutableHash', - is => 'ro', - isa => 'HashRef[Str]', - default => sub { {} }, - handles => { - get_option => 'get', - has_options => 'empty', - get_option_list => 'keys', - } - ); - -=head1 DESCRIPTION - -This module provides a immutable HashRef attribute which provides a number of -hash-line operations. See L -for more details. - -=head1 METHODS - -=over 4 - -=item B - -=item B - -=item B - -=back - -=head1 BUGS - -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. - -=head1 AUTHOR - -Stevan Little Estevan@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2007-2009 by Infinity Interactive, Inc. - -L - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut diff --git a/lib/Moose/Meta/Attribute/Trait/Native/List.pm b/lib/Moose/Meta/Attribute/Trait/Native/List.pm deleted file mode 100644 index 180bff0..0000000 --- a/lib/Moose/Meta/Attribute/Trait/Native/List.pm +++ /dev/null @@ -1,95 +0,0 @@ - -package Moose::Meta::Attribute::Trait::Native::List; -use Moose::Role; - -our $VERSION = '0.87'; -$VERSION = eval $VERSION; -our $AUTHORITY = 'cpan:STEVAN'; - -use Moose::Meta::Attribute::Trait::Native::MethodProvider::List; - -with 'Moose::Meta::Attribute::Trait::Native::Collection'; - -has 'method_provider' => ( - is => 'ro', - isa => 'ClassName', - predicate => 'has_method_provider', - default => 'Moose::Meta::Attribute::Trait::Native::MethodProvider::List' -); - -sub _helper_type { 'ArrayRef' } - -no Moose::Role; - -package # hide me from search.cpan.org - Moose::Meta::Attribute::Custom::Trait::List; -sub register_implementation { - 'Moose::Meta::Attribute::Trait::Native::List' -} - - -1; - -__END__ - -=pod - -=head1 NAME - -Moose::Meta::Attribute::Trait::Native::List - -=head1 SYNOPSIS - - package Stuff; - use Moose; - use Moose::AttributeHelpers; - - has 'options' => ( - metaclass => 'List', - is => 'ro', - isa => 'ArrayRef[Int]', - default => sub { [] }, - handles => { - map_options => 'map', - filter_options => 'grep', - } - ); - -=head1 DESCRIPTION - -This module provides an List attribute which provides a number of -list operations. See L -for more details. - -=head1 METHODS - -=over 4 - -=item B - -=item B - -=item B - -=back - -=head1 BUGS - -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. - -=head1 AUTHOR - -Stevan Little Estevan@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2007-2009 by Infinity Interactive, Inc. - -L - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut diff --git a/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/Array.pm b/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/Array.pm index d302645..5e5ac72 100644 --- a/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/Array.pm +++ b/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/Array.pm @@ -5,7 +5,92 @@ our $VERSION = '0.87'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; -with 'Moose::Meta::Attribute::Trait::Native::MethodProvider::List'; +sub count : method { + my ( $attr, $reader, $writer ) = @_; + return sub { + scalar @{ $reader->( $_[0] ) }; + }; +} + +sub empty : method { + my ( $attr, $reader, $writer ) = @_; + return sub { + scalar @{ $reader->( $_[0] ) } ? 1 : 0; + }; +} + +sub find : method { + my ( $attr, $reader, $writer ) = @_; + return sub { + my ( $instance, $predicate ) = @_; + foreach my $val ( @{ $reader->($instance) } ) { + return $val if $predicate->($val); + } + return; + }; +} + +sub map : method { + my ( $attr, $reader, $writer ) = @_; + return sub { + my ( $instance, $f ) = @_; + CORE::map { $f->($_) } @{ $reader->($instance) }; + }; +} + +sub sort : method { + my ( $attr, $reader, $writer ) = @_; + return sub { + my ( $instance, $predicate ) = @_; + die "Argument must be a code reference" + if $predicate && ref $predicate ne 'CODE'; + + if ($predicate) { + CORE::sort { $predicate->( $a, $b ) } @{ $reader->($instance) }; + } + else { + CORE::sort @{ $reader->($instance) }; + } + }; +} + +sub grep : method { + my ( $attr, $reader, $writer ) = @_; + return sub { + my ( $instance, $predicate ) = @_; + CORE::grep { $predicate->($_) } @{ $reader->($instance) }; + }; +} + +sub elements : method { + my ( $attr, $reader, $writer ) = @_; + return sub { + my ($instance) = @_; + @{ $reader->($instance) }; + }; +} + +sub join : method { + my ( $attr, $reader, $writer ) = @_; + return sub { + my ( $instance, $separator ) = @_; + join $separator, @{ $reader->($instance) }; + }; +} + +sub first : method { + my ( $attr, $reader, $writer ) = @_; + return sub { + $reader->( $_[0] )->[0]; + }; +} + +sub last : method { + my ( $attr, $reader, $writer ) = @_; + return sub { + $reader->( $_[0] )->[-1]; + }; +} sub push : method { my ( $attr, $reader, $writer ) = @_; @@ -248,6 +333,36 @@ __END__ Moose::Meta::Attribute::Trait::Native::MethodProvider::Array +=head1 SYNOPSIS + + package Stuff; + use Moose; + use Moose::AttributeHelpers; + + has 'options' => ( + metaclass => 'Array', + is => 'rw', + isa => 'ArrayRef[Str]', + default => sub { [] }, + auto_deref => 1, + handles => { + all_options => 'elements', + map_options => 'map', + filter_options => 'grep', + find_option => 'find', + first_option => 'first', + last_option => 'last', + get_option => 'get', + join_options => 'join', + count_options => 'count', + do_i_have_options => 'empty', + sorted_options => 'sort', + } + ); + + no Moose; + 1; + =head1 DESCRIPTION This is a role which provides the method generators for @@ -263,13 +378,102 @@ L. =head1 PROVIDED METHODS -This module also consumes the B method providers, to -see those provided methods, refer to that documentation. - =over 4 +=item B + +Returns the number of elements in the array. + + $stuff = Stuff->new; + $stuff->options(["foo", "bar", "baz", "boo"]); + + my $count = $stuff->count_options; + print "$count\n"; # prints 4 + +=item B + +If the array is populated, returns true. Otherwise, returns false. + + $stuff->do_i_have_options ? print "Good boy.\n" : die "No options!\n" ; + +=item B + +This method accepts a subroutine reference as its argument. That sub +will receive each element of the array in turn. If it returns true for +an element, that element will be returned by the C method. + + my $found = $stuff->find_option( sub { $_[0] =~ /^b/ } ); + print "$found\n"; # prints "bar" + +=item B + +This method accepts a subroutine reference as its argument. This +method returns every element for which that subroutine reference +returns a true value. + + my @found = $stuff->filter_options( sub { $_[0] =~ /^b/ } ); + print "@found\n"; # prints "bar baz boo" + +=item B + +This method accepts a subroutine reference as its argument. The +subroutine will be executed for each element of the array. It is +expected to return a modified version of that element. The return +value of the method is a list of the modified options. + + my @mod_options = $stuff->map_options( sub { $_[0] . "-tag" } ); + print "@mod_options\n"; # prints "foo-tag bar-tag baz-tag boo-tag" + +=item B + +Sorts and returns the elements of the array. + +You can provide an optional subroutine reference to sort with (as you +can with the core C function). However, instead of using C<$a> +and C<$b>, you will need to use C<$_[0]> and C<$_[1]> instead. + + # ascending ASCIIbetical + my @sorted = $stuff->sort_options(); + + # Descending alphabetical order + my @sorted_options = $stuff->sort_options( sub { lc $_[1] cmp lc $_[0] } ); + print "@sorted_options\n"; # prints "foo boo baz bar" + +=item B + +Returns all of the elements of the array + + my @option = $stuff->all_options; + print "@options\n"; # prints "foo bar baz boo" + +=item B + +Joins every element of the array using the separator given as argument. + + my $joined = $stuff->join_options( ':' ); + print "$joined\n"; # prints "foo:bar:baz:boo" + =item B +Returns an element of the array by its index. + + my $option = $stuff->get_option(1); + print "$option\n"; # prints "bar" + +=item B + +Returns the first element of the array. + + my $first = $stuff->first_option; + print "$first\n"; # prints "foo" + +=item B + +Returns the last element of the array. + + my $last = $stuff->last_option; + print "$last\n"; # prints "boo" + =item B =item B diff --git a/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/Hash.pm b/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/Hash.pm index 8cf1f6c..173de8b 100644 --- a/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/Hash.pm +++ b/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/Hash.pm @@ -5,7 +5,65 @@ our $VERSION = '0.87'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; -with 'Moose::Meta::Attribute::Trait::Native::MethodProvider::ImmutableHash'; +sub exists : method { + my ( $attr, $reader, $writer ) = @_; + return sub { CORE::exists $reader->( $_[0] )->{ $_[1] } ? 1 : 0 }; +} + +sub defined : method { + my ( $attr, $reader, $writer ) = @_; + return sub { CORE::defined $reader->( $_[0] )->{ $_[1] } ? 1 : 0 }; +} + +sub get : method { + my ( $attr, $reader, $writer ) = @_; + return sub { + if ( @_ == 2 ) { + $reader->( $_[0] )->{ $_[1] }; + } + else { + my ( $self, @keys ) = @_; + @{ $reader->($self) }{@keys}; + } + }; +} + +sub keys : method { + my ( $attr, $reader, $writer ) = @_; + return sub { CORE::keys %{ $reader->( $_[0] ) } }; +} + +sub values : method { + my ( $attr, $reader, $writer ) = @_; + return sub { CORE::values %{ $reader->( $_[0] ) } }; +} + +sub kv : method { + my ( $attr, $reader, $writer ) = @_; + return sub { + my $h = $reader->( $_[0] ); + map { [ $_, $h->{$_} ] } CORE::keys %{$h}; + }; +} + +sub elements : method { + my ( $attr, $reader, $writer ) = @_; + return sub { + my $h = $reader->( $_[0] ); + map { $_, $h->{$_} } CORE::keys %{$h}; + }; +} + +sub count : method { + my ( $attr, $reader, $writer ) = @_; + return sub { scalar CORE::keys %{ $reader->( $_[0] ) } }; +} + +sub empty : method { + my ( $attr, $reader, $writer ) = @_; + return sub { scalar CORE::keys %{ $reader->( $_[0] ) } ? 1 : 0 }; +} + sub set : method { my ( $attr, $reader, $writer ) = @_; @@ -149,28 +207,20 @@ L role. =item B -Returns the number of elements in the hash. - -=item B - -Removes the element with the given key - -=item B - -Returns true if the value of a given key is defined +Returns the number of elements in the list. =item B If the list is populated, returns true. Otherwise, returns false. -=item B - -Unsets the hash entirely. - =item B Returns true if the given key is present in the hash +=item B + +Returns true if the value of a given key is defined + =item B Returns an element of the hash by its key. @@ -179,17 +229,29 @@ Returns an element of the hash by its key. Returns the list of keys in the hash. -=item B - -Sets the element in the hash at the given key to the given value. - =item B Returns the list of values in the hash. =item B -Returns the key, value pairs in the hash +Returns the key, value pairs in the hash as array references + +=item B + +Returns the key, value pairs in the hash as a flattened list + +=item B + +Removes the element with the given key + +=item B + +Unsets the hash entirely. + +=item B + +Sets the element in the hash at the given key to the given value. =item B diff --git a/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/ImmutableHash.pm b/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/ImmutableHash.pm deleted file mode 100644 index 1ea1fef..0000000 --- a/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/ImmutableHash.pm +++ /dev/null @@ -1,152 +0,0 @@ -package Moose::Meta::Attribute::Trait::Native::MethodProvider::ImmutableHash; -use Moose::Role; - -our $VERSION = '0.87'; -$VERSION = eval $VERSION; -our $AUTHORITY = 'cpan:STEVAN'; - -sub exists : method { - my ( $attr, $reader, $writer ) = @_; - return sub { CORE::exists $reader->( $_[0] )->{ $_[1] } ? 1 : 0 }; -} - -sub defined : method { - my ( $attr, $reader, $writer ) = @_; - return sub { CORE::defined $reader->( $_[0] )->{ $_[1] } ? 1 : 0 }; -} - -sub get : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - if ( @_ == 2 ) { - $reader->( $_[0] )->{ $_[1] }; - } - else { - my ( $self, @keys ) = @_; - @{ $reader->($self) }{@keys}; - } - }; -} - -sub keys : method { - my ( $attr, $reader, $writer ) = @_; - return sub { CORE::keys %{ $reader->( $_[0] ) } }; -} - -sub values : method { - my ( $attr, $reader, $writer ) = @_; - return sub { CORE::values %{ $reader->( $_[0] ) } }; -} - -sub kv : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - my $h = $reader->( $_[0] ); - map { [ $_, $h->{$_} ] } CORE::keys %{$h}; - }; -} - -sub elements : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - my $h = $reader->( $_[0] ); - map { $_, $h->{$_} } CORE::keys %{$h}; - }; -} - -sub count : method { - my ( $attr, $reader, $writer ) = @_; - return sub { scalar CORE::keys %{ $reader->( $_[0] ) } }; -} - -sub empty : method { - my ( $attr, $reader, $writer ) = @_; - return sub { scalar CORE::keys %{ $reader->( $_[0] ) } ? 1 : 0 }; -} - -1; - -__END__ - -=pod - -=head1 NAME - -Moose::Meta::Attribute::Trait::Native::MethodProvider::ImmutableHash - -=head1 DESCRIPTION - -This is a role which provides the method generators for -L. - -=head1 METHODS - -=over 4 - -=item B - -=back - -=head1 PROVIDED METHODS - -=over 4 - -=item B - -Returns the number of elements in the list. - -=item B - -If the list is populated, returns true. Otherwise, returns false. - -=item B - -Returns true if the given key is present in the hash - -=item B - -Returns true if the value of a given key is defined - -=item B - -Returns an element of the hash by its key. - -=item B - -Returns the list of keys in the hash. - -=item B - -Returns the list of values in the hash. - -=item B - -Returns the key, value pairs in the hash as array references - -=item B - -Returns the key, value pairs in the hash as a flattened list - -=back - -=head1 BUGS - -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. - -=head1 AUTHOR - -Stevan Little Estevan@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2007-2009 by Infinity Interactive, Inc. - -L - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut - diff --git a/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/List.pm b/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/List.pm deleted file mode 100644 index 3c340b5..0000000 --- a/lib/Moose/Meta/Attribute/Trait/Native/MethodProvider/List.pm +++ /dev/null @@ -1,274 +0,0 @@ -package Moose::Meta::Attribute::Trait::Native::MethodProvider::List; -use Moose::Role; - -our $VERSION = '0.87'; -$VERSION = eval $VERSION; -our $AUTHORITY = 'cpan:STEVAN'; - -sub count : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - scalar @{ $reader->( $_[0] ) }; - }; -} - -sub empty : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - scalar @{ $reader->( $_[0] ) } ? 1 : 0; - }; -} - -sub find : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - my ( $instance, $predicate ) = @_; - foreach my $val ( @{ $reader->($instance) } ) { - return $val if $predicate->($val); - } - return; - }; -} - -sub map : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - my ( $instance, $f ) = @_; - CORE::map { $f->($_) } @{ $reader->($instance) }; - }; -} - -sub sort : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - my ( $instance, $predicate ) = @_; - die "Argument must be a code reference" - if $predicate && ref $predicate ne 'CODE'; - - if ($predicate) { - CORE::sort { $predicate->( $a, $b ) } @{ $reader->($instance) }; - } - else { - CORE::sort @{ $reader->($instance) }; - } - }; -} - -sub grep : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - my ( $instance, $predicate ) = @_; - CORE::grep { $predicate->($_) } @{ $reader->($instance) }; - }; -} - -sub elements : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - my ($instance) = @_; - @{ $reader->($instance) }; - }; -} - -sub join : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - my ( $instance, $separator ) = @_; - join $separator, @{ $reader->($instance) }; - }; -} - -sub get : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - $reader->( $_[0] )->[ $_[1] ]; - }; -} - -sub first : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - $reader->( $_[0] )->[0]; - }; -} - -sub last : method { - my ( $attr, $reader, $writer ) = @_; - return sub { - $reader->( $_[0] )->[-1]; - }; -} - -1; - -__END__ - -=pod - -=head1 NAME - -Moose::Meta::Attribute::Trait::Native::MethodProvider::List - -=head1 SYNOPSIS - - package Stuff; - use Moose; - use Moose::AttributeHelpers; - - has 'options' => ( - metaclass => 'List', - is => 'rw', - isa => 'ArrayRef[Str]', - default => sub { [] }, - auto_deref => 1, - handles => { - all_options => 'elements', - map_options => 'map', - filter_options => 'grep', - find_option => 'find', - first_option => 'first', - last_option => 'last', - get_option => 'get', - join_options => 'join', - count_options => 'count', - do_i_have_options => 'empty', - sorted_options => 'sort', - } - ); - - no Moose; - 1; - -=head1 DESCRIPTION - -This is a role which provides the method generators for -L. - -=head1 METHODS - -=over 4 - -=item B - -=back - -=head1 PROVIDED METHODS - -=over 4 - -=item B - -Returns the number of elements in the list. - - $stuff = Stuff->new; - $stuff->options(["foo", "bar", "baz", "boo"]); - - my $count = $stuff->count_options; - print "$count\n"; # prints 4 - -=item B - -If the list is populated, returns true. Otherwise, returns false. - - $stuff->do_i_have_options ? print "Good boy.\n" : die "No options!\n" ; - -=item B - -This method accepts a subroutine reference as its argument. That sub -will receive each element of the list in turn. If it returns true for -an element, that element will be returned by the C method. - - my $found = $stuff->find_option( sub { $_[0] =~ /^b/ } ); - print "$found\n"; # prints "bar" - -=item B - -This method accepts a subroutine reference as its argument. This -method returns every element for which that subroutine reference -returns a true value. - - my @found = $stuff->filter_options( sub { $_[0] =~ /^b/ } ); - print "@found\n"; # prints "bar baz boo" - -=item B - -This method accepts a subroutine reference as its argument. The -subroutine will be executed for each element of the list. It is -expected to return a modified version of that element. The return -value of the method is a list of the modified options. - - my @mod_options = $stuff->map_options( sub { $_[0] . "-tag" } ); - print "@mod_options\n"; # prints "foo-tag bar-tag baz-tag boo-tag" - -=item B - -Sorts and returns the elements of the list. - -You can provide an optional subroutine reference to sort with (as you -can with the core C function). However, instead of using C<$a> -and C<$b>, you will need to use C<$_[0]> and C<$_[1]> instead. - - # ascending ASCIIbetical - my @sorted = $stuff->sort_options(); - - # Descending alphabetical order - my @sorted_options = $stuff->sort_options( sub { lc $_[1] cmp lc $_[0] } ); - print "@sorted_options\n"; # prints "foo boo baz bar" - -=item B - -Returns all of the elements of the list - - my @option = $stuff->all_options; - print "@options\n"; # prints "foo bar baz boo" - -=item B - -Joins every element of the list using the separator given as argument. - - my $joined = $stuff->join_options( ':' ); - print "$joined\n"; # prints "foo:bar:baz:boo" - -=item B - -Returns an element of the list by its index. - - my $option = $stuff->get_option(1); - print "$option\n"; # prints "bar" - -=item B - -Returns the first element of the list. - - my $first = $stuff->first_option; - print "$first\n"; # prints "foo" - -=item B - -Returns the last element of the list. - - my $last = $stuff->last_option; - print "$last\n"; # prints "boo" - -=back - -=head1 BUGS - -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. - -=head1 AUTHOR - -Stevan Little Estevan@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2007-2009 by Infinity Interactive, Inc. - -L - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut diff --git a/t/070_attribute_helpers/205_trait_list.t b/t/070_attribute_helpers/205_trait_list.t index d3ca58e..e72f509 100644 --- a/t/070_attribute_helpers/205_trait_list.t +++ b/t/070_attribute_helpers/205_trait_list.t @@ -16,7 +16,7 @@ my $up; use Moose::AttributeHelpers; has '_options' => ( - traits => ['List'], + traits => ['Array'], is => 'ro', isa => 'ArrayRef[Int]', init_arg => 'options', @@ -112,7 +112,7 @@ is_deeply( [ $stuff->descending ], [ reverse 1 .. 10 ] ); ## test the meta my $options = $stuff->meta->get_attribute('_options'); -does_ok( $options, 'Moose::Meta::Attribute::Trait::Native::List' ); +does_ok( $options, 'Moose::Meta::Attribute::Trait::Native::Array' ); is_deeply( $options->handles,