From: Jesse Luehrs Date: Fri, 11 Sep 2009 03:44:08 +0000 (-0500) Subject: clean up some of the native trait docs X-Git-Tag: 0.90~64 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2420461cec6b3360acbefe59bdd7d1627184055a;p=gitmo%2FMoose.git clean up some of the native trait docs --- diff --git a/lib/Moose/Meta/Attribute/Native.pm b/lib/Moose/Meta/Attribute/Native.pm index 2476de5..ebfe231 100644 --- a/lib/Moose/Meta/Attribute/Native.pm +++ b/lib/Moose/Meta/Attribute/Native.pm @@ -60,30 +60,31 @@ Moose::Meta::Attribute::Native - Extend your attribute interfaces my $obj = MyClass->new; $obj->set_quantity(10); # quantity => 10 - $obj->set_mapping(4, 'foo'); # 4 => 'foo' - $obj->set_mapping(5, 'bar'); # 5 => 'bar' - $obj->set_mapping(6, 'baz'); # 6 => 'baz' + $obj->set_mapping('foo', 4); # foo => 4 + $obj->set_mapping('bar', 5); # bar => 5 + $obj->set_mapping('baz', 6); # baz => 6 - # prints 'bar' - print $obj->get_mapping(5) if $obj->exists_in_mapping(5); + # prints 5 + print $obj->get_mapping('bar') if $obj->exists_in_mapping('bar'); - # prints '4, 5, 6' + # prints 'quantity, foo, bar, baz' print join ', ', $obj->ids_in_mapping; =head1 DESCRIPTION While L attributes provide a way to name your accessors, readers, -writers, clearers and predicates, this library provides commonly +writers, clearers and predicates, this set of traits provides commonly used attribute helper methods for more specific types of data. As seen in the L, you specify the data structure via the -C parameter. Available meta classes are below; see L. +C parameter. Available traits are below; see L. This module used to exist as the L extension. It was very commonly used, so we moved it into core Moose. Since this gave us a chance to change the interface, you will have to change your code or continue using -the L extension. +the L extension. L should +continue to work. =head1 PARAMETERS diff --git a/lib/Moose/Meta/Attribute/Native/Trait.pm b/lib/Moose/Meta/Attribute/Native/Trait.pm index d7cfaf7..46b20de 100644 --- a/lib/Moose/Meta/Attribute/Native/Trait.pm +++ b/lib/Moose/Meta/Attribute/Native/Trait.pm @@ -138,7 +138,7 @@ __END__ =head1 NAME -Moose::Meta::Attribute::Native::Trait - base role for helpers +Moose::Meta::Attribute::Native::Trait - Base role for helpers =head1 BUGS diff --git a/lib/Moose/Meta/Attribute/Native/Trait/Array.pm b/lib/Moose/Meta/Attribute/Native/Trait/Array.pm index 4ceb35b..d66da74 100644 --- a/lib/Moose/Meta/Attribute/Native/Trait/Array.pm +++ b/lib/Moose/Meta/Attribute/Native/Trait/Array.pm @@ -29,7 +29,7 @@ __END__ =head1 NAME -Moose::Meta::Attribute::Native::Trait::Array +Moose::Meta::Attribute::Native::Trait::Array - Helper trait for ArrayRef attributes =head1 SYNOPSIS diff --git a/lib/Moose/Meta/Attribute/Native/Trait/Bool.pm b/lib/Moose/Meta/Attribute/Native/Trait/Bool.pm index f38a3b4..e2f670a 100644 --- a/lib/Moose/Meta/Attribute/Native/Trait/Bool.pm +++ b/lib/Moose/Meta/Attribute/Native/Trait/Bool.pm @@ -29,7 +29,7 @@ no Moose::Role; =head1 NAME -Moose::Meta::Attribute::Native::Trait::Bool +Moose::Meta::Attribute::Native::Trait::Bool - Helper trait for Bool attributes =head1 SYNOPSIS @@ -93,8 +93,6 @@ Equivalent of 'not C<$value>'. =item B -=item B - =item B =item B diff --git a/lib/Moose/Meta/Attribute/Native/Trait/Counter.pm b/lib/Moose/Meta/Attribute/Native/Trait/Counter.pm index 7cbb3b9..49a7f66 100644 --- a/lib/Moose/Meta/Attribute/Native/Trait/Counter.pm +++ b/lib/Moose/Meta/Attribute/Native/Trait/Counter.pm @@ -47,7 +47,7 @@ __END__ =head1 NAME -Moose::Meta::Attribute::Native::Trait::Counter +Moose::Meta::Attribute::Native::Trait::Counter - Helper trait for counters =head1 SYNOPSIS diff --git a/lib/Moose/Meta/Attribute/Native/Trait/Hash.pm b/lib/Moose/Meta/Attribute/Native/Trait/Hash.pm index 86f28a3..c353a72 100644 --- a/lib/Moose/Meta/Attribute/Native/Trait/Hash.pm +++ b/lib/Moose/Meta/Attribute/Native/Trait/Hash.pm @@ -29,7 +29,7 @@ __END__ =head1 NAME -Moose::Meta::Attribute::Native::Trait::Hash +Moose::Meta::Attribute::Native::Trait::Hash - Helper trait for HashRef attributes =head1 SYNOPSIS diff --git a/lib/Moose/Meta/Attribute/Native/Trait/Number.pm b/lib/Moose/Meta/Attribute/Native/Trait/Number.pm index 7846d80..7e35b19 100644 --- a/lib/Moose/Meta/Attribute/Native/Trait/Number.pm +++ b/lib/Moose/Meta/Attribute/Native/Trait/Number.pm @@ -58,7 +58,7 @@ no Moose::Role; =head1 NAME -Moose::Meta::Attribute::Native::Trait::Number +Moose::Meta::Attribute::Native::Trait::Number - Helper trait for Num attributes =head1 SYNOPSIS @@ -66,9 +66,9 @@ Moose::Meta::Attribute::Native::Trait::Number use Moose; has 'integer' => ( - metaclass => 'Number', + traits => ['Number'], is => 'ro', - isa => 'Int', + isa => 'Num', default => 5, handles => { set => 'set', @@ -108,19 +108,19 @@ Adds the current value of the attribute to C<$value>. =item B -Subtracts the current value of the attribute to C<$value>. +Subtracts C<$value> from the current value of the attribute. =item B -Multiplies the current value of the attribute to C<$value>. +Multiplies the current value of the attribute by C<$value>. =item B -Divides the current value of the attribute to C<$value>. +Divides the current value of the attribute by C<$value>. =item B -Modulus the current value of the attribute to C<$value>. +Returns the current value of the attribute modulo C<$value>. =item B diff --git a/lib/Moose/Meta/Attribute/Native/Trait/String.pm b/lib/Moose/Meta/Attribute/Native/Trait/String.pm index 278c109..8900614 100644 --- a/lib/Moose/Meta/Attribute/Native/Trait/String.pm +++ b/lib/Moose/Meta/Attribute/Native/Trait/String.pm @@ -44,7 +44,7 @@ __END__ =head1 NAME -Moose::Meta::Attribute::Native::Trait::String +Moose::Meta::Attribute::Native::Trait::String - Helper trait for Str attributes =head1 SYNOPSIS @@ -75,15 +75,15 @@ completion. If your attribute definition does not include any of I, I, I or I but does use the C metaclass, then this module applies defaults as in the L -above. This allows for a very basic counter definition: +above. This allows for a very basic string definition: - has 'foo' => (metaclass => 'String'); + has 'foo' => (traits => ['String']); $obj->append_foo; =head1 PROVIDED METHODS These methods are implemented in -L. It is important to +L. It is important to note that all those methods do in place modification of the value stored in the attribute.