line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RDF::Generator::Void::Meta::Attribute::ObjectList; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
2619
|
use Moose::Role; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
53
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
RDF::Generator::Void::Meta::Attribute::ObjectList - Trait for list of RDF objects |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has _endpoints => ( traits => ['ObjectList'] ); |
13
|
|
|
|
|
|
|
has _titles => ( |
14
|
|
|
|
|
|
|
traits => ['ObjectList'], |
15
|
|
|
|
|
|
|
isa => 'ArrayRef[RDF::Trine::Node::Literal]', |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
has resources => ( traits => ['ObjectList'] ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This module gives you a trait to manage a list of RDF resources |
22
|
|
|
|
|
|
|
typically used in an object position in an RDF triple. When declaring |
23
|
|
|
|
|
|
|
attributes, you may use C<traits => ['ObjectList']> alone in which |
24
|
|
|
|
|
|
|
case it'll give you a arrayref of strings and the methods to push to |
25
|
|
|
|
|
|
|
the array, list all strings in the array, and to check if it is |
26
|
|
|
|
|
|
|
empty. These are created by prefixing C<add_>, C<all_> and C<has_no_> |
27
|
|
|
|
|
|
|
to your attribute name, respectively. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
If you have an underscore in the beginning, the attribute will not |
30
|
|
|
|
|
|
|
itself be a method, but you can still use the non-prefixed attribute |
31
|
|
|
|
|
|
|
name as argument to the constructor, and you will have the same methods as above. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
You may also give a C<isa> argument to the attribute. In that case, |
34
|
|
|
|
|
|
|
you may set the arrayref to contain something other than strings, like |
35
|
|
|
|
|
|
|
in the example above. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
with ( |
40
|
|
|
|
|
|
|
'Moose::Meta::Attribute::Native::Trait::Array', |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
around _process_options => sub { |
44
|
|
|
|
|
|
|
my $orig = shift; |
45
|
|
|
|
|
|
|
my (undef, $attr_name, $options) = @_; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$options->{is} = 'rw'; |
48
|
|
|
|
|
|
|
$options->{isa} = 'ArrayRef[Str]' unless exists $options->{isa}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
if ($attr_name =~ /^_(.+)/) { |
51
|
|
|
|
|
|
|
$attr_name = $1; |
52
|
|
|
|
|
|
|
$options->{init_arg} = $attr_name; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# WTF isn't this like crazy to add traits to the class in a trait. Hmm, Nah, that's okay. |
56
|
|
|
|
|
|
|
$options->{traits} = [] unless exists $options->{traits}; |
57
|
|
|
|
|
|
|
push @{ $options->{traits} }, 'Moose::Meta::Attribute::Native::Trait::Array'; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$options->{default} = sub {[]}; |
60
|
|
|
|
|
|
|
$options->{handles} = { |
61
|
|
|
|
|
|
|
sprintf("add_%s", $attr_name) => 'push', |
62
|
|
|
|
|
|
|
sprintf("all_%s", $attr_name) => 'uniq', |
63
|
|
|
|
|
|
|
sprintf("has_no_%s", $attr_name) => 'is_empty', |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
$orig->(@_); |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 FURTHER DOCUMENTATION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Please see L<RDF::Generator::Void> for further documentation. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHORS AND COPYRIGHT |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This module was prototyped by Konstantin Baierer and is mostly his work. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Please see L<RDF::Generator::Void> for more information about authors |
79
|
|
|
|
|
|
|
and copyright for this module. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |