| 1 | package UR::Object::Property; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 266 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 266 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 266 | require UR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 266 | ▶ | use Lingua::EN::Inflect; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 266 | ▶ | use Class::AutoloadCAN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 266 | our $VERSION = "0.47"; # UR $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 266 | our @CARP_NOT = qw( UR::DataSource::RDBMS UR::Object::Type ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # class_meta and r_class_meta duplicate the functionality if two properties of the same name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # but these are faster | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub class_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
class_meta: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | return shift->{'class_name'}->class->__meta__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub r_class_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
r_class_meta: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | return shift->{'data_type'}->class->__meta__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub is_direct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_direct: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | if ($self->is_calculated or $self->is_constant or $self->is_many or $self->via) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$self->is_calculated or $self->is_constant or $self->is_many or $self->via
$self->is_calculated or $self->is_constant or $self->is_many
$self->is_calculated or $self->is_constant
MC/DC0%0/4
$self->is_calculated or $self->is_constant or $self->is_many or $self->via
$self->is_calculated
$self->is_constant
$self->is_many
$self->via
Truth table0%0/5
A or B or C or D
A= $self->is_calculatedB= $self->is_constantC= $self->is_manyD= $self->via
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub is_numeric { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_numeric: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | unless (defined($self->{'_is_numeric'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my $class = $self->_data_type_as_class_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | unless ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $self->{'_is_numeric'} = $class->isa("UR::Value::Number"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | return $self->{'_is_numeric'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub is_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_text: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | unless (defined($self->{'_is_text'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my $class = $self->_data_type_as_class_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | unless ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $self->{'_is_text'} = $class->isa("UR::Value::Text"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | return $self->{'_is_text'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub is_valid_storage_for_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid_storage_for_value: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $data_class_name = $self->_data_type_as_class_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return 1 if ($value->isa($data_class_name)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if ($data_class_name->isa('UR::Value') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my @underlying_types = $data_class_name->underlying_data_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | foreach my $underlying_type ( @underlying_types ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | return 1 if ($value->isa($underlying_type)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub alias_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alias_for: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ($self->{'via'} and $self->{'to'} and $self->{'via'} eq '__self__') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->{"via"} and $self->{"to"} and $self->{"via"} eq "__self__"
$self->{"via"} and $self->{"to"}
MC/DC0%0/3
$self->{"via"} and $self->{"to"} and $self->{"via"} eq "__self__"
$self->{"via"}
$self->{"to"}
$self->{"via"} eq "__self__"
Truth table0%0/4
A and B and C
A= $self->{"via"}B= $self->{"to"}C= $self->{"via"} eq "__self__"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return $self->{'to'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | return $self->{'property_name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub _convert_data_type_for_source_class_to_final_class { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_data_type_for_source_class_to_final_class: not called CC=20 SCAR=60.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my ($class, $foreign_class, $source_class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | $foreign_class ||= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$foreign_class ||= ""
MC/DC0%0/1
$foreign_class ||= ""
$foreign_class
Truth table0%0/2
A
A= $foreign_class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # TODO: allowing "is => 'Text'" instead of is => 'UR::Value::Text' is syntactic sugar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # We should have an is_primitive flag set on these so we do efficient work. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my ($ns) = ($source_class =~ /^([^:]+)::/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if ($ns and not $ns->isa("UR::Namespace")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ns and not $ns->isa("UR::Namespace")
MC/DC0%0/2
$ns and not $ns->isa("UR::Namespace")
$ns
not $ns->isa("UR::Namespace")
Truth table0%0/3
A and not(B)
A= $nsB= not $ns->isa("UR::Namespace")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $ns = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $final_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if ($foreign_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ($foreign_class->can('__meta__')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $final_class = $foreign_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my ($ns_value_class, $ur_value_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if ($ns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$ns and $ns ne "UR" and $ns ne "URT" and $ns->can("get")
$ns and $ns ne "UR" and $ns ne "URT"
$ns and $ns ne "UR"
MC/DC0%0/4
$ns and $ns ne "UR" and $ns ne "URT" and $ns->can("get")
$ns
$ns ne "UR"
$ns ne "URT"
$ns->can("get")
Truth table0%0/5
A and B and C and D
A= $nsB= $ns ne "UR"C= $ns ne "URT"D= $ns->can("get")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | and $ns ne 'UR' and $ns ne 'URT' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | and $ns->can("get") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $ns_value_class = $ns . '::Value::' . $foreign_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ($ns_value_class->can('__meta__')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $final_class = $ns_value_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if (!$final_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $ur_value_class = 'UR::Value::' . $foreign_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $normalized_ur_value_class = 'UR::Value::' . ucfirst(lc($foreign_class)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ($normalized_ur_value_class->can('__meta__')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $final_class = $normalized_ur_value_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } elsif ($ur_value_class->can('__meta__')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $final_class = $ur_value_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if (!$final_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | if (Class::Autouse->class_exists($foreign_class)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return $foreign_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | elsif ($foreign_class =~ /::/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | return $foreign_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | eval "use $foreign_class;"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if (!$@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | return $foreign_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if (!$ns or $ns->get()->allow_sloppy_primitives) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $ns or $ns->get->allow_sloppy_primitives
MC/DC0%0/2
not $ns or $ns->get->allow_sloppy_primitives
not $ns
$ns->get->allow_sloppy_primitives
Truth table0%0/3
not(A) or B
A= not $nsB= $ns->get->allow_sloppy_primitives
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # no colons, and no namespace: no choice but to assume it's a sloppy primitive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | return 'UR::Value::SloppyPrimitive'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | Carp::confess("Failed to find a ${ns}::Value::* or UR::Value::* module for primitive type $foreign_class!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | return $final_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub _data_type_as_class_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_type_as_class_name: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | return $self->{_data_type_as_class_name} ||= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_data_type_as_class_name"} ||= do {
my $source_class = $self->class_name;
my $foreign_class = $self->data_type;
unless ($foreign_class) {
if ($self->via or $self->to) {
my(@joins) = "UR::Object::Join"->resolve_chain($self->class_name, $self->property_name, $self->property_name);
$foreign_class = $joins[-1]->foreign_class;
};
};
__PACKAGE__->_convert_data_type_for_source_class_to_final_class($foreign_class, $source_class)
}
MC/DC0%0/2
$self->{"_data_type_as_class_name"} ||= do {
my $source_class = $self->class_name;
my $foreign_class = $self->data_type;
unless ($foreign_class) {
if ($self->via or $self->to) {
my(@joins) = "UR::Object::Join"->resolve_chain($self->class_name, $self->property_name, $self->property_name);
$foreign_class = $joins[-1]->foreign_class;
};
};
__PACKAGE__->_convert_data_type_for_source_class_to_final_class($foreign_class, $source_class)
}
$self->{"_data_type_as_class_name"}
do {
my $source_class = $self->class_name;
my $foreign_class = $self->data_type;
unless ($foreign_class) {
if ($self->via or $self->to) {
my(@joins) = "UR::Object::Join"->resolve_chain($self->class_name, $self->property_name, $self->property_name);
$foreign_class = $joins[-1]->foreign_class;
};
};
__PACKAGE__->_convert_data_type_for_source_class_to_final_class($foreign_class, $source_class)
}
Truth table0%0/3
A ||= B
A= $self->{"_data_type_as_class_name"}B= do {
my $source_class = $self->class_name;
my $foreign_class = $self->data_type;
unless ($foreign_class) {
if ($self->via or $self->to) {
my(@joins) = "UR::Object::Join"->resolve_chain($self->class_name, $self->property_name, $self->property_name);
$foreign_class = $joins[-1]->foreign_class;
};
};
__PACKAGE__->_convert_data_type_for_source_class_to_final_class($foreign_class, $source_class)
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $source_class = $self->class_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | #this is so NUMBER -> Number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $foreign_class = $self->data_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if (not $foreign_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if ($self->via or $self->to) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->via or $self->to
MC/DC0%0/2
$self->via or $self->to
$self->via
$self->to
Truth table0%0/3
A or B
A= $self->viaB= $self->to
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my @joins = UR::Object::Join->resolve_chain( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | $self->class_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | $self->property_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | $self->property_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $foreign_class = $joins[-1]->foreign_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | __PACKAGE__->_convert_data_type_for_source_class_to_final_class($foreign_class, $source_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # TODO: this is a method on the data source which takes a given property. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # Returns the table and column for this property. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # If this particular property doesn't have a column_name, and it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # overrides a property defined on a parent class, then walk up the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # inheritance and find the right one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub table_and_column_name_for_property { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table_and_column_name_for_property: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # Shortcut - this property has a column_name, so the class should have the right | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # table_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | if ($self->column_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | return ($self->class_name->__meta__->table_name, $self->column_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my $property_name = $self->property_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my @class_metas = $self->class_meta->parent_class_metas; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | while (@class_metas) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my $class_meta = shift @class_metas; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | next if ($seen{$class_meta}++); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $p = $class_meta->property_meta_for_name($property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | next unless $p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if ($p->column_name && $class_meta->table_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$p->column_name and $class_meta->table_name
MC/DC0%0/2
$p->column_name and $class_meta->table_name
$p->column_name
$class_meta->table_name
Truth table0%0/3
A and B
A= $p->column_nameB= $class_meta->table_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | return ($class_meta->table_name, $p->column_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | push @class_metas, $class_meta->parent_class_metas; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # This property has no column anywhere in the class' inheritance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # Return true if resolution of this property involves an ID property of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # any class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub _involves_id_property { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_involves_id_property: not called CC=18 SCAR=58.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my $is_id = $self->is_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | return 1 if defined($is_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if ($self->id_by) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my $class_meta = $self->class_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $id_by_list = $self->id_by; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | foreach my $id_by ( @$id_by_list ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my $id_by_meta = $class_meta->property_meta_for_name($id_by); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | return 1 if ($id_by_meta and $id_by_meta->_involves_id_property); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$id_by_meta and $id_by_meta->_involves_id_property
MC/DC0%0/2
$id_by_meta and $id_by_meta->_involves_id_property
$id_by_meta
$id_by_meta->_involves_id_property
Truth table0%0/3
A and B
A= $id_by_metaB= $id_by_meta->_involves_id_property
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | if ($self->via) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $via_meta = $self->via_property_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | return 1 if ($via_meta and $via_meta ne $self and $via_meta->_involves_id_property); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$via_meta and $via_meta ne $self and $via_meta->_involves_id_property
$via_meta and $via_meta ne $self
MC/DC0%0/3
$via_meta and $via_meta ne $self and $via_meta->_involves_id_property
$via_meta
$via_meta ne $self
$via_meta->_involves_id_property
Truth table0%0/4
A and B and C
A= $via_metaB= $via_meta ne $selfC= $via_meta->_involves_id_property
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | if ($self->to) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $to_meta = $self->to_property_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | return 1 if ($to_meta and $to_meta->_involves_id_property); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$to_meta and $to_meta->_involves_id_property
MC/DC0%0/2
$to_meta and $to_meta->_involves_id_property
$to_meta
$to_meta->_involves_id_property
Truth table0%0/3
A and B
A= $to_metaB= $to_meta->_involves_id_property
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if ($self->where) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | unless ($to_meta) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | Carp::confess("Property '" . $self->property_name . "' of class " . $self->class_name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | . " has 'to' metadata that does not resolve to a known property."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my $other_class_meta = $to_meta->class_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $where = $self->where; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | for (my $i = 0; $i < @$where; $i += 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my $where_meta = $other_class_meta->property_meta_for_name($where->[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | return 1 if ($where_meta and $where_meta->_involves_id_property); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$where_meta and $where_meta->_involves_id_property
MC/DC0%0/2
$where_meta and $where_meta->_involves_id_property
$where_meta
$where_meta->_involves_id_property
Truth table0%0/3
A and B
A= $where_metaB= $where_meta->_involves_id_property
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # For via/to delegated properties, return the property meta in the same | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # class this property delegates through | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub via_property_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
via_property_meta: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | return unless ($self->is_delegated and $self->via); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->is_delegated and $self->via
MC/DC0%0/2
$self->is_delegated and $self->via
$self->is_delegated
$self->via
Truth table0%0/3
A and B
A= $self->is_delegatedB= $self->via
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $class_meta = $self->class_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | return $class_meta->property_meta_for_name($self->via); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | sub final_property_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
final_property_meta: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $closure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | $closure = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | return unless defined $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if ($_[0]->is_delegated and $_[0]->via) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_[0]->is_delegated and $_[0]->via
MC/DC0%0/2
$_[0]->is_delegated and $_[0]->via
$_[0]->is_delegated
$_[0]->via
Truth table0%0/3
A and B
A= $_[0]->is_delegatedB= $_[0]->via
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if ($_[0]->to) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | return $closure->($_[0]->to_property_meta); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | return $closure->($_[0]->via_property_meta); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $final = $closure->($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | return if !defined $final || $final->id eq $self->id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $final or $final->id eq $self->id
MC/DC0%0/2
not defined $final or $final->id eq $self->id
not defined $final
$final->id eq $self->id
Truth table0%0/3
not(A) or B
A= not defined $finalB= $final->id eq $self->id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | return $final; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # For via/to delegated properties, return the property meta on the foreign | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # class that this property delegates to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | sub to_property_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_property_meta: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | return unless ($self->is_delegated && $self->to); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->is_delegated and $self->to
MC/DC0%0/2
$self->is_delegated and $self->to
$self->is_delegated
$self->to
Truth table0%0/3
A and B
A= $self->is_delegatedB= $self->to
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $via_meta = $self->via_property_meta(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | return unless $via_meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $remote_class = $via_meta->data_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # unless ($remote_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # # Can we guess what the data type is for multiply indirect properties? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # if ($via_meta->to) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # my $to_property_meta = $via_meta->to_property_meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # $remote_class = $to_property_meta->data_type if ($to_property_meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | return unless $remote_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my $remote_class_meta = UR::Object::Type->get($remote_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | return unless $remote_class_meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return $remote_class_meta->property_meta_for_name($self->to); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | sub get_property_name_pairs_for_join { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_property_name_pairs_for_join: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | unless ($self->{'_get_property_name_pairs_for_join'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my @linkage = $self->_get_direct_join_linkage(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | unless (@linkage) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | Carp::croak("Cannot resolve underlying property joins for property '" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | . $self->property_name . "' of class " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | . $self->class_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | . ": Couldn't determine which properties link to the remote class"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my @results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | if ($self->reverse_as) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | @results = map { [ $_->[1] => $_->[0] ] } @linkage; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | @results = map { [ $_->[0] => $_->[1] ] } @linkage; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $self->{'_get_property_name_pairs_for_join'} = \@results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | return @{$self->{'_get_property_name_pairs_for_join'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | sub _get_direct_join_linkage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_direct_join_linkage: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my @retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if (my $id_by = $self->id_by) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my $r_class_meta = $self->r_class_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | unless ($r_class_meta) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | Carp::croak("Property '" . $self->property_name . "' of class '" . $self->class_name . "' " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | . "has data_type '" . $self->data_type ."' with no class metadata"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my @my_id_by = @{ $self->id_by }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my @their_id_by = @{ $r_class_meta->{'id_by'} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | if (! @their_id_by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not @their_id_by or @my_id_by == 1 and @their_id_by > 1
@my_id_by == 1 and @their_id_by > 1
MC/DC0%0/3
not @their_id_by or @my_id_by == 1 and @their_id_by > 1
not @their_id_by
@my_id_by == 1
@their_id_by > 1
Truth table0%0/4
not(A) or B and C
A= not @their_id_byB= @my_id_by == 1C= @their_id_by > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | (@my_id_by == 1 and @their_id_by > 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | @their_id_by = ( 'id' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | unless (@my_id_by == @their_id_by) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | Carp::croak("Property '" . $self->property_name . "' of class '" . $self->class_name . "' " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | . "has " . scalar(@my_id_by) . " id_by elements, while its data_type (" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | . $self->data_type .") has " . scalar(@their_id_by)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | for (my $i = 0; $i < @my_id_by; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | push @retval, [ $my_id_by[$i], $their_id_by[$i] ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | elsif (my $reverse_as = $self->reverse_as) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my $r_class_name = $self->data_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | @retval = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | $r_class_name->__meta__->property_meta_for_name($reverse_as)->_get_direct_join_linkage(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | return @retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | sub _resolve_join_chain { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_join_chain: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | return UR::Object::Join->resolve_chain( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | $self->class_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | $self->property_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | sub label_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label_text: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | # The name of the property in friendly terms. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my ($self,$obj) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | my $property_name = $self->property_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | my @words = App::Vocabulary->filter_vocabulary(map { ucfirst(lc($_)) } split(/\s+/,$property_name)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my $label = join(" ", @words); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | return $label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | # This gets around the need to make a custom property subclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | # when a class has an attributes_have specification. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # This primary example of this in base infrastructure is that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # all Commands have is_input, is_output and is_param attributes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # Note: it's too permissive and will make an accessor for any hash key. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | # The updated code should not do this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 13566 | ▶ | sub CAN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CAN: called CC=5 SCAR=28.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 13566 | my ($thisclass, $method, $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 13566 | ▶ | if (ref($self)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my $accessor_key = '_' . $method . "_accessor"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if (my $method = $self->{$accessor_key}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | return $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | if ($self->class_name->__meta__->{attributes_have} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->class_name->__meta__->{"attributes_have"} and exists $self->class_name->__meta__->{"attributes_have"}{$method}
MC/DC0%0/2
$self->class_name->__meta__->{"attributes_have"} and exists $self->class_name->__meta__->{"attributes_have"}{$method}
$self->class_name->__meta__->{"attributes_have"}
exists $self->class_name->__meta__->{"attributes_have"}{$method}
Truth table0%0/3
A and B
A= $self->class_name->__meta__->{"attributes_have"}B= exists $self->class_name->__meta__->{"attributes_have"}{$method}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | exists $self->class_name->__meta__->{attributes_have}{$method} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | return $self->{$accessor_key} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | return $_[0]->{$method}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 13566 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 266 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | UR::Object::Property - Class representing metadata about a class property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | my $prop = UR::Object::Property->get(class_name => 'Some::Class', property_name => 'foo'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | my $class_meta = Some::Class->__meta__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | my $prop2 = $class_meta->property_meta_for_name('foo'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # Print out the meta-property name and its value of $prop2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | print map { " $_ : ".$prop2->$_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | qw(class_name property_name data_type default_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | Instances of this class represent properties of classes. For every item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | mentioned in the 'has' or 'id_by' section of a class definition become Property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | objects. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | =head1 INHERITANCE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | UR::Object::Property is a subclass of L<UR::Object> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | =head1 PROPERTY TYPES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | For this class definition: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | class Some::Class { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | has => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | other_id => { is => 'Text' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | other => { is => 'Some::Other', id_by => 'foo_id' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | bar => { via => 'other', to => 'bar' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | foos => { is => 'Some::Foo', reverse_as => 'some', is_many => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | uc_other_id => { calculate_from => 'other_id', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | calculate_perl => 'uc($other_id)' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | Properties generally fall in to one of these categories: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | =item regular property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | A regular property of a class holds a single scalar. In this case, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 'other_id' is a regular property. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | =item object accessor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | An object accessor property returns objects of some class. The properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | of this class must link in some way with all the ID properties of the remote | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | class (the 'is' declaration). 'other' is an object accessor property. This | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | is how one-to-one relationships are implemented. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | =item via property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | When a class has some object accessor property, and it is helpful for an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | object to assume the value of the remote class's properties, you can set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | up a 'via' property. In the example above, an object of this class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | gets the value of its 'bar' property via the 'other' object it's linked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | to, from that object's 'bar' property. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | =item reverse as or is many property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | This is how one-to-many relationships are implemented. In this case, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | the Some::Foo class must have an object accessor property called 'some', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | and the 'foos' property will return a list of all the Some::Foo objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | where their 'some' property would have returned that object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | =item calculated property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | A calculated property doesn't store its data directly in the object, but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | when its accessor is called, the calculation code is executed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | =head1 PROPERTIES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | Each property has a method of the same name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | =head2 Direct Properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | =item class_name => Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | The name of the class this Property is attached to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | =item property_name => Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | The name of the property. The pair of class_name and property name are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | the ID properties of UR::Object::Property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | =item column_name => Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | If the class is backed by a database table, then the column this property's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | data comes from is stored here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | =item data_type => Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | The type of data stored in this property. Corresponds to the 'is' part of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | a class's property definition. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | =item data_length => Number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | The maximum size of data stored in this property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | =item default_value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | For is_optional properties, the default value given when an object is created | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | and this property is not assigned a value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | =item valid_values => ARRAY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | A listref of enumerated values this property may be set to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | =item doc => Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | A place for documentation about this property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | =item is_id => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | Indicates whether this is an ID property of the class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | =item is_optional => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | Indicates whether this is property may have the value undef when the object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | is created | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | =item is_transient => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | Indicates whether this is property is transient? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | =item is_constant => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | Indicates whether this property can be changed after the object is created. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | =item is_mutable => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | Indicates this property can be changed via its accessor. Properties cannot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | be both constant and mutable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | =item is_volatile => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | Indicates this property can be changed by a mechanism other than its normal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | accessor method. Signals are not emitted even when it does change via | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | its normal accessor method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | =item is_classwide => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | Indicates this property's storage is shared among all instances of the class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | When the value is changed for one instance, that change is effective for all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | instances. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | =item is_delegated => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | Indicates that the value for this property is not stored in the object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | directly, but is delegated to another object or class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | =item is_calculated => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | Indicates that the value for this property is not a part of the object'd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | data directly, but is calculated in some way. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | =item is_transactional => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | Indicates the changes to the value of this property is tracked by a Context's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | transaction and can be rolled back if necessary. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | =item is_abstract => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | Indicates this property exists in a base class, but must be overridden in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | a derived class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | =item is_concrete => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | Antonym for is_abstract. Properties cannot be both is_abstract and is_concrete, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | =item is_final => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | Indicates this property cannot be overridden in a derived class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | =item is_deprecated => Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | Indicates this property's use is deprecated. It has no effect in the use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | of the property in any way, but is useful in documentation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | =item implied_by => Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | If this property is created as a result of another property's existence, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | implied_by is the name of that other property. This can happen in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | case where an object accessor property is defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | has => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | foo => { is => 'Some::Other', id_by => 'foo_id' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | Here, the 'foo' property requires another property called 'foo_id', which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | is not explicitly declared. In this case, the Property named foo_id will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | have its implied_by set to 'foo'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | =item id_by => ARRAY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | In the case of an object accessor property, this is the list of properties in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | this class that link to the ID properties in the remote class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | =item reverse_as => Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | Defines the linking property name in the remote class in the case of an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | is_many relationship | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | =item via => Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | For a via-type property, indicates which object accessor to go through. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | =item to => Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | For a via-type property, indicates the property name in the remote class to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | get its value from. The default value is the same as property_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | =item where => ARRAY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | Supplies additional filters for indirect properties. For example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | foos => { is => 'Some::Foo', reverse_as => 'some', is_many => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | blue_foos => { via => 'foos', where => [ color => 'blue' ] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | Would create a property 'blue_foos' which returns only the related | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | Some::Foo objects that have 'blue' color. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | =item calculate_from => ARRAY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | For calculated properties, this is a list of other property names the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | calculation is based on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | =item calculate_perl => Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | For calculated properties, a string containing Perl code. Any properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | mentioned in calculate_from will exist in the code's scope at run time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | as scalars of the same name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | =item class_meta => UR::Object::Type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | Returns the class metaobject of the class this property belongs to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | =item via_property_meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | For via/to delegated properties, return the property meta in the same | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | class this property delegates through | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | =item to_property_meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | For via/to delegated properties, return the property meta on the foreign | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | class that this property delegates to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | UR::Object::Type, UR::Object::Type::Initializer, UR::Object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||