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