X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FAutobox%2FHash.pm;h=997440d69aa9702e50a3fc5ac66a56fee9d75ce8;hb=31d40d7362f4154746428525561af751208b0805;hp=2cc99a3f6a8d8c3f3cee3c6f6b9d6ce65d04ee9a;hpb=5f654d8ec893246d215ae8a3b0fa9b467d50b3b9;p=gitmo%2FMoose-Autobox.git diff --git a/lib/Moose/Autobox/Hash.pm b/lib/Moose/Autobox/Hash.pm index 2cc99a3..997440d 100644 --- a/lib/Moose/Autobox/Hash.pm +++ b/lib/Moose/Autobox/Hash.pm @@ -3,20 +3,84 @@ use Moose::Role 'with'; our $VERSION = '0.01'; -with 'Moose::Autobox::Ref'; +with 'Moose::Autobox::Ref', + 'Moose::Autobox::Indexed'; + + + +sub delete { + my ($hash, $key) = @_; + CORE::delete $hash->{$key}; +} + +# ::Indexed implementation + +sub at { + my ($hash, $index) = @_; + $hash->{$index}; +} + +sub put { + my ($hash, $index, $value) = @_; + $hash->{$index} = $value; +} sub exists { my ($hash, $key) = @_; CORE::exists $hash->{$key}; } + sub keys { my ($hash) = @_; - [ CORE::keys %{$hash} ]; + [ CORE::keys %$hash ]; } sub values { my ($hash) = @_; - [ CORE::values %{$hash} ]; + [ CORE::values %$hash ]; } -1; \ No newline at end of file +sub kv { + my ($hash) = @_; + [ CORE::map { [ $_, $hash->{$_} ] } CORE::keys %$hash ]; +} + +1; + +__END__ + +=pod + +=head1 NAME + +Moose::Autobox::Hash - the Hash role + +=head1 SYNOPOSIS + + use Moose::Autobox; + use autobox; + + { one => 1, two => 2 }->keys->join(', ')->print; # prints 'one, two' + +=head1 DESCRIPTION + +=head1 BUGS + +All complex software has bugs lurking in it, and this module is no +exception. If you find a bug please either email me, or add the bug +to cpan-RT. + +=head1 AUTHOR + +Stevan Little Estevan@iinteractive.comE + +=head1 COPYRIGHT AND LICENSE + +Copyright 2006 by Infinity Interactive, Inc. + +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