| 1 | use Renard::Incunabula::Common::Setup; | ||
| 2 | package Intertangle::Punchcard::Attributes; | ||
| 3 | # ABSTRACT: Attributes for constraint variables | ||
| 4 | $Intertangle::Punchcard::Attributes::VERSION = '0.002'; | ||
| 5 | use Moo::_Utils qw(_install_coderef); | ||
| 6 | use Intertangle::Punchcard::Backend::Kiwisolver::Symbolic; | ||
| 7 | |||
| 8 | sub import { | ||
| 9 | my $target = caller; | ||
| 10 | my $has = $target->can( "has" ) or die "Moo not loaded in caller: $target"; | ||
| 11 | _install_coderef $target. "::variable" => my $variable = sub { | ||
| 12 | my ($name, @args) = @_; | ||
| 13 | $has->($name, | ||
| 14 | is => 'lazy', | ||
| 15 | builder => sub { | ||
| 16 | Intertangle::Punchcard::Backend::Kiwisolver::Symbolic->new( name => $name ); | ||
| 17 | }, | ||
| 18 | @args, | ||
| 19 | ); | ||
| 20 | }; | ||
| 21 | |||
| 22 | if (my $info = $Role::Tiny::INFO{$target}) { | ||
| 23 | $info->{not_methods}{$variable} = $variable; | ||
| 24 | } | ||
| 25 | |||
| 26 | undef; | ||
| 27 | } | ||
| 28 | |||
| 29 | 1; | ||
| 30 | |||
| 31 | __END__ |