add hash slices
[gitmo/Moose-Autobox.git] / lib / Moose / Autobox / Hash.pm
index 8000d29..0bcb420 100644 (file)
@@ -3,7 +3,7 @@ use Moose::Role 'with';
 
 use Carp qw(croak);
 
-our $VERSION = '0.02';
+our $VERSION = '0.03';
 
 with 'Moose::Autobox::Ref',
      'Moose::Autobox::Indexed';
@@ -52,6 +52,11 @@ sub kv {
     [ CORE::map { [ $_, $hash->{$_} ] } CORE::keys %$hash ];    
 }
 
+sub slice {
+    my ($hash, $keys) = @_;
+    return [ @{$hash}{@$keys} ];
+};
+
 sub print   { CORE::print %{$_[0]} }
 sub say     { CORE::print %{$_[0]}, "\n" }
 
@@ -104,6 +109,8 @@ shallow merging.
 
 =item B<kv>
 
+=item B<slice>
+
 =back
 
 =over 4