a711f98e4a0dc2e18e0bacbc3bca63d1f405e10d
[scpubgit/DKit.git] / lib / DX / Var.pm
1 package DX::Var;
2
3 use Moo;
4
5 has id => (is => 'ro', required => 1);
6
7 has bound_stream => (is => 'ro');
8
9 has bound_value => (is => 'lazy', clearer => 1, builder => sub {
10   $_[0]->bound_stream->next;
11 });
12
13 sub with_stream {
14   my ($self, $stream) = @_;
15   $self->new(%$self, bound_stream => $stream);
16 }
17
18 sub with_value {
19   my ($self, $stream) = @_;
20   $self->new(%$self, bound_value => $stream);
21 }
22
23 1;