X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FAttributeHelpers%2FMethodProvider%2FImmutableHash.pm;h=3bb6a3abdc87922d074ec6364db7838f9d9c0229;hb=2e74144c8801485e5c33fdcdcbee9f7d882c1a3a;hp=3db47156e932b67cd21590a9764bf9c2b712f194;hpb=f82de33de79e5fcab70be9b8acf9cbad6efa133b;p=gitmo%2FMooseX-AttributeHelpers.git diff --git a/lib/MooseX/AttributeHelpers/MethodProvider/ImmutableHash.pm b/lib/MooseX/AttributeHelpers/MethodProvider/ImmutableHash.pm index 3db4715..3bb6a3a 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.16'; +our $VERSION = '0.23'; $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])} }; @@ -86,20 +96,40 @@ L. =item B +Returns the number of elements in the list. + =item B +If the list is populated, returns true. Otherwise, returns false. + =item B +Returns true if the given key is present in the hash + =item B +Returns true if the value of a given key is defined + =item B +Returns an element of the hash by its key. + =item B +Returns the list of keys in the hash. + =item B +Returns the list of values in the hash. + =item B +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 =head1 BUGS @@ -114,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