From: 2shortplanks Date: Mon, 7 Sep 2009 10:08:09 +0000 (+0100) Subject: Change documention for get and get to reflect actual behavior. X-Git-Tag: 0.89_02~33^2~5^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=85592815da28bbf09d153c9d80afb47fecd8f0c7;hp=e22d28f22f15b0ea66e4bff6fec33bab2c088687;p=gitmo%2FMoose.git Change documention for get and get to reflect actual behavior. Add test to ensure scalar usage of ->get remains the same now it's documented. --- diff --git a/lib/Moose/Meta/Attribute/Native/Trait/Hash.pm b/lib/Moose/Meta/Attribute/Native/Trait/Hash.pm index 9d57157..999bbc8 100644 --- a/lib/Moose/Meta/Attribute/Native/Trait/Hash.pm +++ b/lib/Moose/Meta/Attribute/Native/Trait/Hash.pm @@ -63,13 +63,16 @@ L. =over 4 -=item B +=item B -Returns an element of the hash by its key. +Returns values from the hash. -=item B +In list context return a list of values in the hash for the given keys. +In scalar context returns the value for the last key specified. -Sets the element in the hash at the given key to the given value. +=item B $value, $key2 => $value2 ...)> + +Sets the elements in the hash to the given values. =item B diff --git a/t/070_native_traits/203_trait_hash.t b/t/070_native_traits/203_trait_hash.t index ef93bc4..7d63286 100644 --- a/t/070_native_traits/203_trait_hash.t +++ b/t/070_native_traits/203_trait_hash.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 46; +use Test::More tests => 47; use Test::Exception; use Test::Moose 'does_ok'; @@ -81,6 +81,9 @@ is( $stuff->get_option('foo'), 'bar', '... got the right option' ); is_deeply( [ $stuff->get_option(qw(foo bar)) ], [qw(bar baz)], "get multiple options at once" ); +is( scalar($stuff->get_option(qw( foo bar) )), "baz", + '... got last option in scalar context'); + lives_ok { $stuff->set_option( oink => "blah", xxy => "flop" ); }