From: Jesse Luehrs Date: Thu, 9 Jul 2009 22:40:39 +0000 (-0500) Subject: we aren't coring Bag X-Git-Tag: 0.89_02~93 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2fdb0e0909b1fc9881608fd2fba6e3a6534c7c54;p=gitmo%2FMoose.git we aren't coring Bag --- diff --git a/lib/Moose/AttributeHelpers.pm b/lib/Moose/AttributeHelpers.pm index a0cc528..177bdaa 100644 --- a/lib/Moose/AttributeHelpers.pm +++ b/lib/Moose/AttributeHelpers.pm @@ -15,7 +15,6 @@ use Moose::AttributeHelpers::Trait::Collection::List; use Moose::AttributeHelpers::Trait::Collection::Array; use Moose::AttributeHelpers::Trait::Collection::Hash; use Moose::AttributeHelpers::Trait::Collection::ImmutableHash; -use Moose::AttributeHelpers::Trait::Collection::Bag; 1; diff --git a/lib/Moose/AttributeHelpers/MethodProvider/Bag.pm b/lib/Moose/AttributeHelpers/MethodProvider/Bag.pm deleted file mode 100644 index 452b7cc..0000000 --- a/lib/Moose/AttributeHelpers/MethodProvider/Bag.pm +++ /dev/null @@ -1,97 +0,0 @@ -package Moose::AttributeHelpers::MethodProvider::Bag; -use Moose::Role; - -our $VERSION = '0.87'; -$VERSION = eval $VERSION; -our $AUTHORITY = 'cpan:STEVAN'; - -with 'Moose::AttributeHelpers::MethodProvider::ImmutableHash'; - -sub add : method { - my ( $attr, $reader, $writer ) = @_; - return sub { $reader->( $_[0] )->{ $_[1] }++ }; -} - -sub delete : method { - my ( $attr, $reader, $writer ) = @_; - return sub { CORE::delete $reader->( $_[0] )->{ $_[1] } }; -} - -sub reset : method { - my ( $attr, $reader, $writer ) = @_; - return sub { $reader->( $_[0] )->{ $_[1] } = 0 }; -} - -1; - -__END__ - -=pod - -=head1 NAME - -Moose::AttributeHelpers::MethodProvider::Bag - -=head1 DESCRIPTION - -This is a role which provides the method generators for -L. - -This role is composed from the -L role. - -=head1 METHODS - -=over 4 - -=item B - -=back - -=head1 PROVIDED METHODS - -=over 4 - -=item B - -=item B - -=item B - -=item B - -=item B - -=item B - -=item B - -=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/AttributeHelpers/Trait/Collection/Bag.pm b/lib/Moose/AttributeHelpers/Trait/Collection/Bag.pm deleted file mode 100644 index 3c66027..0000000 --- a/lib/Moose/AttributeHelpers/Trait/Collection/Bag.pm +++ /dev/null @@ -1,102 +0,0 @@ - -package Moose::AttributeHelpers::Trait::Collection::Bag; -use Moose::Role; -use Moose::Util::TypeConstraints; - -our $VERSION = '0.87'; -$VERSION = eval $VERSION; -our $AUTHORITY = 'cpan:STEVAN'; - -use Moose::AttributeHelpers::MethodProvider::Bag; - -with 'Moose::AttributeHelpers::Trait::Collection'; - -has 'method_provider' => ( - is => 'ro', - isa => 'ClassName', - predicate => 'has_method_provider', - default => 'Moose::AttributeHelpers::MethodProvider::Bag' -); - -subtype 'Bag' => as 'HashRef[Int]'; - -sub _helper_type { 'Bag' } - -sub _default_default { sub { {} } } - -no Moose::Role; -no Moose::Util::TypeConstraints; - -package # hide me from search.cpan.org - Moose::Meta::Attribute::Custom::Trait::Collection::Bag; -sub register_implementation { - 'Moose::AttributeHelpers::Trait::Collection::Bag' -} - -1; - -__END__ - -=pod - -=head1 NAME - -Moose::AttributeHelpers::Collection::Bag - -=head1 SYNOPSIS - - package Stuff; - use Moose; - use Moose::AttributeHelpers; - - has 'word_histogram' => ( - metaclass => 'Collection::Bag', - is => 'ro', - isa => 'Bag', # optional ... as is defalt - handles => { - add_word => 'add', - get_count_for => 'get', - has_any_words => 'empty', - num_words => 'count', - delete_word => 'delete', - } - ); - -=head1 DESCRIPTION - -This module provides a Bag attribute which provides a number of -bag-like 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/t/070_attribute_helpers/206_trait_bag.t b/t/070_attribute_helpers/206_trait_bag.t deleted file mode 100644 index 5309f3d..0000000 --- a/t/070_attribute_helpers/206_trait_bag.t +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More tests => 19; -use Test::Exception; -use Test::Moose 'does_ok'; - -{ - - package Stuff; - use Moose; - use Moose::AttributeHelpers; - - has 'word_histogram' => ( - traits => ['Collection::Bag'], - is => 'ro', - handles => { - 'add_word' => 'add', - 'get_count_for' => 'get', - 'has_any_words' => 'empty', - 'num_words' => 'count', - 'delete_word' => 'delete', - } - ); -} - -my $stuff = Stuff->new(); -isa_ok( $stuff, 'Stuff' ); - -can_ok( $stuff, $_ ) for qw[ - add_word - get_count_for - has_any_words - num_words - delete_word -]; - -ok( !$stuff->has_any_words, '... we have no words' ); -is( $stuff->num_words, 0, '... we have no words' ); - -lives_ok { - $stuff->add_word('bar'); -} -'... set the words okay'; - -ok( $stuff->has_any_words, '... we have words' ); -is( $stuff->num_words, 1, '... we have 1 word(s)' ); -is( $stuff->get_count_for('bar'), 1, '... got words now' ); - -lives_ok { - $stuff->add_word('foo'); - $stuff->add_word('bar') for 0 .. 3; - $stuff->add_word('baz') for 0 .. 10; -} -'... set the words okay'; - -is( $stuff->num_words, 3, '... we still have 1 word(s)' ); -is( $stuff->get_count_for('foo'), 1, '... got words now' ); -is( $stuff->get_count_for('bar'), 5, '... got words now' ); -is( $stuff->get_count_for('baz'), 11, '... got words now' ); - -## test the meta - -my $words = $stuff->meta->get_attribute('word_histogram'); -does_ok( $words, 'Moose::AttributeHelpers::Trait::Collection::Bag' ); - -is_deeply( - $words->handles, - { - 'add_word' => 'add', - 'get_count_for' => 'get', - 'has_any_words' => 'empty', - 'num_words' => 'count', - 'delete_word' => 'delete', - }, - '... got the right handles mapping' -); -