X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FAutobox%2FHash.pm;h=ba2eb218f42b4f5345872baa13780bd271973ce1;hb=b3cb70385763ff1067a42fa7e470177bef3485e8;hp=f8766b9f1475a18ef920b2bdc250fdd3fe1517ac;hpb=260cc81f7ab424f417900ab1c44b734b339f9d9e;p=gitmo%2FMoose-Autobox.git
diff --git a/lib/Moose/Autobox/Hash.pm b/lib/Moose/Autobox/Hash.pm
index f8766b9..ba2eb21 100644
--- a/lib/Moose/Autobox/Hash.pm
+++ b/lib/Moose/Autobox/Hash.pm
@@ -1,7 +1,9 @@
package Moose::Autobox::Hash;
use Moose::Role 'with';
-our $VERSION = '0.01';
+use Carp qw(croak);
+
+our $VERSION = '0.02';
with 'Moose::Autobox::Ref',
'Moose::Autobox::Indexed';
@@ -11,6 +13,13 @@ sub delete {
CORE::delete $hash->{$key};
}
+sub merge {
+ my ($left, $right) = @_;
+ croak "You must pass a hashref as argument to merge"
+ unless ref $right eq 'HASH';
+ return { %$left, %$right };
+}
+
# ::Indexed implementation
sub at {
@@ -43,6 +52,9 @@ sub kv {
[ CORE::map { [ $_, $hash->{$_} ] } CORE::keys %$hash ];
}
+sub print { CORE::print %{$_[0]} }
+sub say { CORE::print %{$_[0]}, "\n" }
+
1;
__END__
@@ -56,23 +68,27 @@ Moose::Autobox::Hash - the Hash role
=head1 SYNOPOSIS
use Moose::Autobox;
- use autobox;
- { one => 1, two => 2 }->keys->join(', ')->print; # prints 'one, two'
+ print { one => 1, two => 2 }->keys->join(', '); # prints 'one, two'
=head1 DESCRIPTION
+This is a role to describes a Hash value.
+
=head1 METHODS
=over 4
-=item B
-
=item B
+=item B
+
+Takes a hashref and returns a new hashref with right precedence
+shallow merging.
+
=back
-=head2 Indexed
+=head2 Indexed implementation
=over 4
@@ -90,6 +106,16 @@ Moose::Autobox::Hash - the Hash role
=back
+=over 4
+
+=item B
+
+=item B
+
+=item B
+
+=back
+
=head1 BUGS
All complex software has bugs lurking in it, and this module is no
@@ -102,11 +128,12 @@ Stevan Little Estevan@iinteractive.comE
=head1 COPYRIGHT AND LICENSE
-Copyright 2006 by Infinity Interactive, Inc.
+Copyright 2006-2007 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
+=cut
+