File Coverage

lib/UR/Object/Property/View/ReferenceDescription/Text.pm
Criterion Covered Total %
statement 6 26 23.0
branch 0 4 0.0
condition n/a
subroutine 2 3 66.6
pod n/a
total 8 33 24.2


line stmt bran cond sub pod time code
1             package UR::Object::Property::View::ReferenceDescription::Text;
2              
3 1     1   14 use strict;
  1         1  
  1         31  
4 1     1   3 use warnings;
  1         1  
  1         284  
5             require UR;
6             our $VERSION = "0.46"; # UR $VERSION;
7              
8             UR::Object::Type->define(
9             class_name => __PACKAGE__,
10             is => 'UR::Object::View::Default::Text',
11             doc => "View used by 'ur show properties' for each object-accessor property",
12             );
13              
14             sub _update_view_from_subject {
15 0     0     my $self = shift;
16              
17 0           my $property_meta = $self->subject;
18 0 0         return unless ($property_meta);
19              
20 0           my $r_class_name = $property_meta->data_type;
21              
22 0           my @relation_detail;
23 0           my @pairs = eval { $property_meta->get_property_name_pairs_for_join() };
  0            
24              
25 0           my $text;
26 0 0         if (@pairs) {
27 0           foreach my $pair ( @pairs ) {
28 0           my($property_name, $r_property_name) = @$pair;
29 0           push @relation_detail, "$r_property_name => \$self->$property_name";
30             }
31 0           my $padding = length($r_class_name) + 34;
32 0           my $relation_detail = join(",\n" . " "x$padding, @relation_detail);
33              
34 0           $text = sprintf(" %22s => %s->get(%s)\n",
35             $property_meta->property_name,
36             $r_class_name,
37             $relation_detail);
38             } else {
39 0           $text = sprintf(" %22s => %s->get(id => \$self->%s)\n",
40             $property_meta->property_name,
41             $r_class_name,
42             $property_meta->property_name);
43             }
44            
45 0           my $widget = $self->widget();
46 0           my $buffer_ref = $widget->[0];
47 0           $$buffer_ref = $text;
48 0           return 1;
49             }
50              
51              
52              
53             1;
54              
55             =pod
56              
57             =head1 NAME
58              
59             UR::Object::Property::View::DescriptionLineItem::Text - View class for UR::Object::Property
60              
61             =head1 DESCRIPTION
62              
63             Used by UR::Namespace::Command::Show::Properties when displaying information about a property
64              
65             =cut