From: Robert 'phaylon' Sedlacek Date: Sun, 12 Aug 2007 01:04:49 +0000 (+0000) Subject: some POD advances X-Git-Tag: 0.18_01~67 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e295d072cf24071b83f12c60933e5620b84a0853;p=gitmo%2FMooseX-AttributeHelpers.git some POD advances --- diff --git a/lib/MooseX/AttributeHelpers.pm b/lib/MooseX/AttributeHelpers.pm index dddde08..ad9e9be 100644 --- a/lib/MooseX/AttributeHelpers.pm +++ b/lib/MooseX/AttributeHelpers.pm @@ -19,12 +19,68 @@ __END__ =head1 NAME -MooseX::AttributeHelpers +MooseX::AttributeHelpers - Extend your attribute interfaces =head1 SYNOPSIS + package MyClass; + use Moose; + + has mapping => ( + metaclass => 'Collection::Hash', + is => 'rw', + isa => 'HashRef', + default => sub { {} }, + provides => { + exists => 'exists_in_mapping', + keys => 'ids_in_mapping', + get => 'get_mapping', + set => 'set_mapping', + }, + ); + + # ... + + my $obj = MyClass->new; + $obj->set_mapping(4, 'foo'); + $obj->set_mapping(5, 'bar'); + $obj->set_mapping(6, 'baz'); + + # prints 'bar' + print $obj->get_mapping(5) if $obj->exists_in_mapping(5); + + # prints '4, 5, 6' + print join ', ', $obj->ids_in_mapping; + =head1 DESCRIPTION +While L attributes provide you with a way to name your accessors, +readers, writers, clearers and predicates, this library provides commonly +used attribute helper methods for more specific types of data. + +As seen in the L, you specify the extension via the +C parameter. Available meta classes are: + +=over + +=item L + +Common numerical operations. + +=item L + +Methods for incrementing and decrementing a counter attribute. + +=item L + +Common methods for hash references. + +=item L + +Common methods for array references. + +=back + =head1 BUGS All complex software has bugs lurking in it, and this module is no @@ -44,4 +100,4 @@ L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -=cut \ No newline at end of file +=cut diff --git a/lib/MooseX/AttributeHelpers/Base.pm b/lib/MooseX/AttributeHelpers/Base.pm index 93f72fb..921ff16 100644 --- a/lib/MooseX/AttributeHelpers/Base.pm +++ b/lib/MooseX/AttributeHelpers/Base.pm @@ -44,7 +44,7 @@ has 'method_constructors' => ( $_ => $method_provider->get_method($_) } $method_provider->get_method_list }; - } + }, ); # extend the parents stuff to make sure @@ -141,8 +141,30 @@ MooseX::AttributeHelpers::Base =head1 DESCRIPTION +Base class for attribute helpers. + +=head1 ATTRIBUTES + +=head2 provides + +=head2 method_provider + +=head2 method_constructors + +=head1 EXTENDED ATTRIBUTES + +=head2 $!default + +C<$!default> is now required. + +=head2 type_constraint + +C is now required. + =head1 METHODS +=head2 helper_type + =head1 BUGS All complex software has bugs lurking in it, and this module is no