X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDX%2FVar.pm;h=2a1f83c0c961fb7f6ded8d10fbc3823d18f28459;hb=d95799c4cfce222bcb8bffd07dd88a5d2d1e69ab;hp=d17f375f8cd0440c5c071bb3633839b0f4347896;hpb=0de441cd75f703bd987450fb0d90c3f57bbfdaf1;p=scpubgit%2FDKit.git diff --git a/lib/DX/Var.pm b/lib/DX/Var.pm index d17f375..2a1f83c 100644 --- a/lib/DX/Var.pm +++ b/lib/DX/Var.pm @@ -4,7 +4,15 @@ use Moo; has id => (is => 'ro', required => 1); -has bound_stream => (is => 'ro'); +has root_set => (is => 'ro', predicate => 1); + +has bound_stream => ( + is => 'lazy', predicate => 1, clearer => 1, + builder => sub { + my ($self) = @_; + $self->root_set->to_stream; + } +); has bound_value => (is => 'lazy', predicate => 1, clearer => 1, builder => sub { if (defined(my $next = $_[0]->bound_stream->next)) { @@ -18,7 +26,7 @@ has action => (is => 'ro'); sub is_bound { my ($self) = @_; - $self->has_bound_value || $self->bound_stream; + $self->has_bound_value || $self->has_bound_stream || $self->has_root_set; } sub with_stream { @@ -36,6 +44,11 @@ sub with_action { $self->new(%$self, action => $action); } +sub with_root_set { + my ($self, $set) = @_; + $self->new(%$self, root_set => $set); +} + sub copy { my ($self) = @_; ref($self)->new(%$self);