|
NAMEMooseX::AttributeHelpers - (DEPRECATED) Extend your attribute interfacesVERSIONversion 0.25SYNOPSISpackage MyClass; use Moose; use MooseX::AttributeHelpers; has 'mapping' => ( metaclass => 'Collection::Hash', is => 'rw', isa => 'HashRef[Str]', default => sub { {} }, provides => { exists => 'exists_in_mapping', keys => 'ids_in_mapping', get => 'get_mapping', set => 'set_mapping', }, curries => { set => { set_quantity => [ 'quantity' ] } } ); # ... 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' # prints 'bar' print $obj->get_mapping(5) if $obj->exists_in_mapping(5); # prints '4, 5, 6' print join ', ', $obj->ids_in_mapping; DESCRIPTIONThis distribution is deprecated. The features it provides have been added to the Moose core code as Moose::Meta::Attribute::Native. This distribution should not be used by any new code.While Moose 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 "SYNOPSIS", you specify the extension via the "metaclass" parameter. Available meta classes are: PARAMETERSprovidesThis points to a hashref that uses "provider" for the keys and "method" for the values. The method will be added to the object itself and do what you want.curriesThis points to a hashref that uses "provider" for the keys and has two choices for the value:You can supply "{method => [ @args ]}" for the values. The method will be added to the object itself (always using @args as the beginning arguments). Another approach to curry a method provider is to supply a coderef instead of an arrayref. The code ref takes $self, $body, and any additional arguments passed to the final method. # ... curries => { grep => { times_with_day => sub { my ($self, $body, $datetime) = @_; $body->($self, sub { $_->ymd eq $datetime->ymd }); } } } # ... $obj->times_with_day(DateTime->now); # takes datetime argument, checks day METHOD PROVIDERS
DEPRECATION NOTICEThe functionality in this family of modules is now implemented in the Moose core as Moose::Meta::Attribute::Native. No more development is being done on MooseX::AttributeHelpers, so we encourage you to switch to native attribute traits.SUPPORTBugs may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-AttributeHelpers> (or bug-MooseX-AttributeHelpers@rt.cpan.org <mailto:bug-MooseX-AttributeHelpers@rt.cpan.org>).There is also a mailing list available for users of this distribution, at <http://lists.perl.org/list/moose.html>. There is also an irc channel available for users of this distribution, at "#moose" on "irc.perl.org" <irc://irc.perl.org/#moose>. AUTHORStevan Little <stevan@iinteractive.com>CONTRIBUTORS
COPYRIGHT AND LICENSEThis software is copyright (c) 2007 by Stevan Little and Infinity Interactive, Inc.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Visit the GSP FreeBSD Man Page Interface. |