foo
[gitmo/Moose-Autobox.git] / lib / Moose / Autobox / Hash.pm
CommitLineData
5f654d8e 1package Moose::Autobox::Hash;
2use Moose::Role 'with';
3
4our $VERSION = '0.01';
5
6cf5bcf2 6with 'Moose::Autobox::Ref',
7 'Moose::Autobox::Indexed';
8
31d40d73 9
10
6cf5bcf2 11sub delete {
12 my ($hash, $key) = @_;
13 CORE::delete $hash->{$key};
14}
15
16# ::Indexed implementation
5f654d8e 17
31d40d73 18sub at {
19 my ($hash, $index) = @_;
20 $hash->{$index};
21}
22
23sub put {
24 my ($hash, $index, $value) = @_;
25 $hash->{$index} = $value;
26}
27
5f654d8e 28sub exists {
29 my ($hash, $key) = @_;
30 CORE::exists $hash->{$key};
31}
e6bb88b0 32
5f654d8e 33sub keys {
34 my ($hash) = @_;
e6bb88b0 35 [ CORE::keys %$hash ];
5f654d8e 36}
37
38sub values {
39 my ($hash) = @_;
e6bb88b0 40 [ CORE::values %$hash ];
41}
42
43sub kv {
44 my ($hash) = @_;
45 [ CORE::map { [ $_, $hash->{$_} ] } CORE::keys %$hash ];
5f654d8e 46}
47
31d40d73 481;
49
50__END__
51
52=pod
53
54=head1 NAME
55
56Moose::Autobox::Hash - the Hash role
57
58=head1 SYNOPOSIS
59
60 use Moose::Autobox;
61 use autobox;
62
63 { one => 1, two => 2 }->keys->join(', ')->print; # prints 'one, two'
64
65=head1 DESCRIPTION
66
67=head1 BUGS
68
69All complex software has bugs lurking in it, and this module is no
70exception. If you find a bug please either email me, or add the bug
71to cpan-RT.
72
73=head1 AUTHOR
74
75Stevan Little E<lt>stevan@iinteractive.comE<gt>
76
77=head1 COPYRIGHT AND LICENSE
78
79Copyright 2006 by Infinity Interactive, Inc.
80
81L<http://www.iinteractive.com>
82
83This library is free software; you can redistribute it and/or modify
84it under the same terms as Perl itself.
85
86=cut