add hslice
[gitmo/Moose-Autobox.git] / lib / Moose / Autobox / Hash.pm
index 0bcb420..2f58a33 100644 (file)
@@ -20,6 +20,11 @@ sub merge {
     return { %$left, %$right };
 }
 
+sub hslice {
+    my ($hash, $keys) = @_;
+    return { map { $_ => $hash->{$_} } @$keys };
+}
+
 # ::Indexed implementation
 
 sub at {
@@ -91,6 +96,10 @@ This is a role to describes a Hash value.
 Takes a hashref and returns a new hashref with right precedence
 shallow merging.
 
+=item B<hslice>
+
+Slices a hash but returns the keys and values as a new hashref.
+
 =back
 
 =head2 Indexed implementation