X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FScope.pm;h=e973adc20d6baa6af64b81c16fe6cc0b2b45b9f4;hb=e6c6fbca8df4f8df7bbce2eb98dd260ed51d9141;hp=c048a1c700fdbd9bcba99b84d990d30f84d54b1a;hpb=32fbc7c8acf36e81b3c3436152e664e79c74dc87;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Scope.pm b/lib/LaTeX/TikZ/Scope.pm index c048a1c..e973adc 100644 --- a/lib/LaTeX/TikZ/Scope.pm +++ b/lib/LaTeX/TikZ/Scope.pm @@ -21,6 +21,12 @@ use LaTeX::TikZ::Tools; use Any::Moose; +=head1 ATTRIBUTES + +=head2 C + +=cut + has '_mods' => ( is => 'ro', isa => 'Maybe[ArrayRef[LaTeX::TikZ::Mod::Formatted]]', @@ -37,6 +43,10 @@ has '_mods_cache' => ( default => sub { +{ } }, ); +=head2 C + +=cut + has '_body' => ( is => 'rw', isa => 'LaTeX::TikZ::Scope|ArrayRef[Str]', @@ -48,13 +58,20 @@ my $ltmf_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Mod::Formatted' my $_body_tc = __PACKAGE__->meta->find_attribute_by_name('_body') ->type_constraint; +=head1 METHODS + +=head2 C + +=cut + sub mod { my $scope = shift; my $cache = $scope->_mods_cache; for (@_) { - my $mod = $ltmf_tc->check($_) ? $_ : $ltmf_tc->coerce($_); + my $mod = $ltmf_tc->coerce($_); + $ltmf_tc->assert_valid($mod); my $tag = $mod->tag; next if exists $cache->{$tag}; $cache->{$tag} = $mod; @@ -64,6 +81,10 @@ sub mod { $scope; } +=head2 C + +=cut + sub body { my $scope = shift; @@ -79,6 +100,10 @@ use overload ( '@{}' => 'dereference', ); +=head2 C + +=cut + sub flatten { my ($scope) = @_; @@ -113,6 +138,10 @@ my $inter = Sub::Name::subname('inter' => sub { return \@left, \@common, \@right; }); +=head2 C + +=cut + sub instantiate { my ($scope) = @_; @@ -163,8 +192,16 @@ sub instantiate { return @body; } +=head2 C + +=cut + sub dereference { [ $_[0]->instantiate ] } +=head2 C + +=cut + sub fold { my ($left, $right, $rev) = @_;