From: Ricardo SIGNES Date: Mon, 12 May 2008 14:16:31 +0000 (+0000) Subject: implement flatten X-Git-Tag: 0_09~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2197a7c093124739caaae6be7b9ae213daefb598;p=gitmo%2FMoose-Autobox.git implement flatten --- diff --git a/Changes b/Changes index 33b9dde..c0a915b 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for Perl extension Moose::Autobox 0.08 + - add flatten method to Array and Hash - upped the dependency on autobox from 1.22 to 2.23 at the suggestion of chocolateboy - might as well up the Moose dependency too. diff --git a/lib/Moose/Autobox/Array.pm b/lib/Moose/Autobox/Array.pm index 6c299a3..4fabd46 100644 --- a/lib/Moose/Autobox/Array.pm +++ b/lib/Moose/Autobox/Array.pm @@ -117,6 +117,10 @@ sub kv { $array->keys->map(sub { [ $_, $array->[$_] ] }); } +sub flatten { + @{$_[0]} +} + ## Junctions sub all { @@ -190,6 +194,8 @@ This is a role to describe operations on the Array type. =item B +=item B + =back =head2 Indexed implementation diff --git a/lib/Moose/Autobox/Hash.pm b/lib/Moose/Autobox/Hash.pm index 62b8946..de8f2bb 100644 --- a/lib/Moose/Autobox/Hash.pm +++ b/lib/Moose/Autobox/Hash.pm @@ -23,6 +23,10 @@ sub hslice { return { map { $_ => $hash->{$_} } @$keys }; } +sub flatten { + return %{$_[0]} +} + # ::Indexed implementation sub at { @@ -98,6 +102,8 @@ shallow merging. Slices a hash but returns the keys and values as a new hashref. +=item B + =back =head2 Indexed implementation diff --git a/lib/Moose/Autobox/List.pm b/lib/Moose/Autobox/List.pm index 8bb4bff..5810ce5 100644 --- a/lib/Moose/Autobox/List.pm +++ b/lib/Moose/Autobox/List.pm @@ -109,4 +109,4 @@ L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -=cut \ No newline at end of file +=cut