| 1 | 50 | ▶ | use v5.14; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 2 | 50 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | |||||||||||||||
| 4 | =head1 NAME | ||||||||||||||
| 5 | |||||||||||||||
| 6 | Attean::Variable - Pattern matching variables | ||||||||||||||
| 7 | |||||||||||||||
| 8 | =head1 VERSION | ||||||||||||||
| 9 | |||||||||||||||
| 10 | This document describes Attean::Variable version 0.040 | ||||||||||||||
| 11 | |||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||
| 13 | |||||||||||||||
| 14 | use v5.14; | ||||||||||||||
| 15 | use Attean; | ||||||||||||||
| 16 | my $term = Attean::Variable->new('name'); | ||||||||||||||
| 17 | $term->ntriples_string; # ?name | ||||||||||||||
| 18 | |||||||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||||||
| 20 | |||||||||||||||
| 21 | The Attean::Variable class represents variables for use in pattern matching. | ||||||||||||||
| 22 | It conforms to the L<Attean::API::TermOrVariable|Attean::API> role. | ||||||||||||||
| 23 | |||||||||||||||
| 24 | =head1 ATTRIBUTES | ||||||||||||||
| 25 | |||||||||||||||
| 26 | =over 4 | ||||||||||||||
| 27 | |||||||||||||||
| 28 | =item C<< value >> | ||||||||||||||
| 29 | |||||||||||||||
| 30 | =item C<< ntriples_string >> | ||||||||||||||
| 31 | |||||||||||||||
| 32 | =back | ||||||||||||||
| 33 | |||||||||||||||
| 34 | =cut | ||||||||||||||
| 35 | |||||||||||||||
| 36 | 50 | package Attean::Variable 0.040 { | |||||||||||||
| 37 | 50 | ▶ | use Moo; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 38 | 50 | ▶ | use Types::Standard qw(Str); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 39 | 50 | ▶ | use UUID::Tiny ':std'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 40 | 50 | ▶ | use namespace::clean; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 41 | |||||||||||||||
| 42 | 50 | has 'value' => (is => 'ro', isa => Str, required => 1); | |||||||||||||
| 43 | 50 | has 'ntriples_string' => (is => 'ro', isa => Str, lazy => 1, builder => '_ntriples_string'); | |||||||||||||
| 44 | |||||||||||||||
| 45 | 50 | with 'Attean::API::Variable'; | |||||||||||||
| 46 | 50 | with 'Attean::API::TermOrVariable'; | |||||||||||||
| 47 | 50 | with 'Attean::API::TermOrVariableOrTriplePattern'; | |||||||||||||
| 48 | |||||||||||||||
| 49 | 892 | ▶ | around BUILDARGS => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||
| 50 | 892 | my $orig = shift; | |||||||||||||
| 51 | 892 | my $class = shift; | |||||||||||||
| 52 | 892 | ▶ | if (scalar(@_) == 0) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 53 | 49 | my $uuid = unpack('H*', create_uuid()); | |||||||||||||
| 54 | 49 | return $class->$orig(value => 'v' . $uuid); | |||||||||||||
| 55 | } elsif (scalar(@_) == 1) { | ||||||||||||||
| 56 | 777 | return $class->$orig(value => shift); | |||||||||||||
| 57 | } | ||||||||||||||
| 58 | 66 | return $class->$orig(@_); | |||||||||||||
| 59 | 50 | }; | |||||||||||||
| 60 | |||||||||||||||
| 61 | 138 | ▶ | sub _ntriples_string { | ||||||||||||
|
Subroutine
_ntriples_string: called CC=1 SCAR=0.0
| |||||||||||||||
| 62 | 138 | my $self = shift; | |||||||||||||
| 63 | 138 | return '?' . $self->value; | |||||||||||||
| 64 | } | ||||||||||||||
| 65 | } | ||||||||||||||
| 66 | |||||||||||||||
| 67 | 50 | 1; | |||||||||||||
| 68 | |||||||||||||||
| 69 | __END__ | ||||||||||||||