| 1 | # RDF::Query::VariableBindings | ||||||||||||||||||||||||||||
| 2 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | RDF::Query::VariableBindings - Variable bindings | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 VERSION | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | This document describes RDF::Query::VariableBindings version 2.919. | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 METHODS | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | Beyond the methods documented below, this class inherits methods from the | ||||||||||||||||||||||||||||
| 15 | L<RDF::Trine::VariableBindings> class. | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =over 4 | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | package RDF::Query::VariableBindings; | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 35 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 35 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 35 | ▶ | use base qw(RDF::Trine::VariableBindings); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 535 | ▶ | use overload '""' => sub { $_[0]->as_string }, | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 35 | ▶ | 'bool' => sub { return 1 }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 35 | ▶ | use Scalar::Util qw(blessed refaddr); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | ###################################################################### | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 35 | our ($VERSION); | |||||||||||||||||||||||||||
| 34 | 35 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | 35 | $VERSION = '2.919'; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | ###################################################################### | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =item C<< new ( \%bindings ) >> | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 798 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 798 | my $class = shift; | |||||||||||||||||||||||||||
| 46 | 798 | ▶ | my $bindings = shift || {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 47 | 798 | my $data = { %$bindings }; | |||||||||||||||||||||||||||
| 48 | 798 | foreach my $k (keys %$data) { | |||||||||||||||||||||||||||
| 49 | 1591 | my $node = $data->{$k}; | |||||||||||||||||||||||||||
| 50 | 1591 | ▶ | if (ref($node) and not($node->isa('RDF::Query::Node'))) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $node and not $node->isa("RDF::Query::Node")
MC/DC100%2/2
ref $node and not $node->isa("RDF::Query::Node")
ref $node
not $node->isa("RDF::Query::Node")
Truth table100%3/3
A and not(B)
A= ref $nodeB= not $node->isa("RDF::Query::Node")
| |||||||||||||||||||||||||||||
| 51 | 753 | $data->{$k} = RDF::Query::Node->from_trine( $node ); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 798 | my $self = $class->SUPER::new( $data ); | |||||||||||||||||||||||||||
| 56 | 798 | return $self; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =item C<< sse ( \%context, $indent ) >> | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =cut | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 7 | ▶ | sub sse { | ||||||||||||||||||||||||||
|
Subroutine
sse: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 65 | 7 | my $context = shift; | |||||||||||||||||||||||||||
| 66 | 7 | my $indent = shift; | |||||||||||||||||||||||||||
| 67 | 7 | my $more = ' '; | |||||||||||||||||||||||||||
| 68 | 7 | my @keys = sort keys %$self; | |||||||||||||||||||||||||||
| 69 | 7 | ▶ | return sprintf('(row %s)', CORE::join(' ', map { '[' . CORE::join(' ', '?' . $_, ($self->{$_}) ? $self->{$_}->as_string : ()) . ']' } (@keys))); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =item C<< explain >> | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | Returns a string serialization of the variable bindings appropriate for display | ||||||||||||||||||||||||||||
| 75 | on the command line. | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =cut | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub explain { | ||||||||||||||||||||||||||
|
Subroutine
explain: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 80 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 81 | 0 | my $s = shift; | |||||||||||||||||||||||||||
| 82 | 0 | my $count = shift; | |||||||||||||||||||||||||||
| 83 | 0 | my $indent = $s x $count; | |||||||||||||||||||||||||||
| 84 | 0 | my $string = "${indent}Variable Bindings\n"; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | my @keys = sort keys %$self; | |||||||||||||||||||||||||||
| 87 | 0 | foreach my $k (@keys) { | |||||||||||||||||||||||||||
| 88 | 0 | $string .= "${indent}${s}$k: " . $self->{$k}->as_string . "\n"; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | 0 | return $string; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =item C<< as_hash >> | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | Returns the variable bindings as a nested set of plain data structures (no objects). | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =cut | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub as_hash { | ||||||||||||||||||||||||||
|
Subroutine
as_hash: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 100 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 101 | 0 | my $context = shift; | |||||||||||||||||||||||||||
| 102 | 0 | my @keys = sort keys %$self; | |||||||||||||||||||||||||||
| 103 | 0 | return { type => 'bindings', bindings => { map { $_ => $self->{$_}->as_hash($context) } @keys } }; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 35 | 1; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | __END__ | ||||||||||||||||||||||||||||