From: Matt S Trout Date: Mon, 3 Feb 2014 03:45:47 +0000 (+0000) Subject: add set_value API X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0ee5d1d4dd9cb8a7f33b013533e20b1e5a83017d;p=scpubgit%2FDKit.git add set_value API --- diff --git a/lib/DX/SetOver.pm b/lib/DX/SetOver.pm index 88a964d..74090bd 100644 --- a/lib/DX/SetOver.pm +++ b/lib/DX/SetOver.pm @@ -15,10 +15,14 @@ sub to_stream { sub with_value { my ($self, $value) = @_; - return ref($self)->new( - %$self, - values => { %{$self->values}, $value->${\$self->over} => $value } - ); + return ref($self)->new(%$self, values => { %{$self->values} }) + ->set_value($value); +} + +sub set_value { + my ($self, $value) = @_; + $self->values->{$value->${\$self->over}} = $value; + return $self; } 1;