Commit | Line | Data |
60cda014 |
1 | package DX::Var; |
2 | |
3 | use Moo; |
4 | |
5 | has id => (is => 'ro', required => 1); |
6 | |
7 | has bound_stream => (is => 'ro'); |
8 | |
b373788e |
9 | has bound_value => (is => 'lazy', predicate => 1, clearer => 1, builder => sub { |
60cda014 |
10 | $_[0]->bound_stream->next; |
11 | }); |
12 | |
b373788e |
13 | sub is_bound { |
14 | my ($self) = @_; |
15 | $self->has_bound_value || $self->bound_stream; |
16 | } |
17 | |
60cda014 |
18 | sub with_stream { |
19 | my ($self, $stream) = @_; |
20 | $self->new(%$self, bound_stream => $stream); |
21 | } |
22 | |
b40d5c51 |
23 | sub with_value { |
24 | my ($self, $stream) = @_; |
25 | $self->new(%$self, bound_value => $stream); |
26 | } |
27 | |
60cda014 |
28 | 1; |