X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FAttributeHelpers%2FMethodProvider%2FImmutableHash.pm;h=dc38ba45b3803d481cd9941963d67f95302c9494;hb=3ebd23e61a6d6f3c4dbda39e3b9d90c0b34d52c5;hp=b6faca03300deeab586910539ee9e9fdfe7e61c8;hpb=de9d98c6a3686c5cc696602da01905fedc7e7548;p=gitmo%2FMooseX-AttributeHelpers.git diff --git a/lib/MooseX/AttributeHelpers/MethodProvider/ImmutableHash.pm b/lib/MooseX/AttributeHelpers/MethodProvider/ImmutableHash.pm index b6faca0..dc38ba4 100644 --- a/lib/MooseX/AttributeHelpers/MethodProvider/ImmutableHash.pm +++ b/lib/MooseX/AttributeHelpers/MethodProvider/ImmutableHash.pm @@ -1,7 +1,7 @@ package MooseX::AttributeHelpers::MethodProvider::ImmutableHash; use Moose::Role; -our $VERSION = '0.17'; +our $VERSION = '0.22'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -47,6 +47,16 @@ sub kv : method { }; } +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])} }; @@ -114,7 +124,11 @@ 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 =back @@ -130,7 +144,7 @@ Stevan Little Estevan@iinteractive.comE =head1 COPYRIGHT AND LICENSE -Copyright 2007-2008 by Infinity Interactive, Inc. +Copyright 2007-2009 by Infinity Interactive, Inc. L