1 package Moose::Autobox::Hash;
2 use Moose::Role 'with';
8 with 'Moose::Autobox::Ref',
9 'Moose::Autobox::Indexed';
12 my ($hash, $key) = @_;
13 CORE::delete $hash->{$key};
17 my ($left, $right) = @_;
18 croak "You must pass a hashref as argument to merge"
19 unless ref $right eq 'HASH';
20 return { %$left, %$right };
23 # ::Indexed implementation
26 my ($hash, $index) = @_;
31 my ($hash, $index, $value) = @_;
32 $hash->{$index} = $value;
36 my ($hash, $key) = @_;
37 CORE::exists $hash->{$key};
42 [ CORE::keys %$hash ];
47 [ CORE::values %$hash ];
52 [ CORE::map { [ $_, $hash->{$_} ] } CORE::keys %$hash ];
55 sub print { CORE::print %{$_[0]} }
56 sub say { CORE::print %{$_[0]}, "\n" }
66 Moose::Autobox::Hash - the Hash role
72 print { one => 1, two => 2 }->keys->join(', '); # prints 'one, two'
76 This is a role to describes a Hash value.
86 Takes a hashref and returns a new hashref with right precedence
91 =head2 Indexed implementation
121 All complex software has bugs lurking in it, and this module is no
122 exception. If you find a bug please either email me, or add the bug
127 Stevan Little E<lt>stevan@iinteractive.comE<gt>
129 =head1 COPYRIGHT AND LICENSE
131 Copyright 2006-2007 by Infinity Interactive, Inc.
133 L<http://www.iinteractive.com>
135 This library is free software; you can redistribute it and/or modify
136 it under the same terms as Perl itself.