line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UR::Value::HASH; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
399
|
use strict; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
224
|
|
4
|
8
|
|
|
8
|
|
29
|
use warnings; |
|
8
|
|
|
|
|
7
|
|
|
8
|
|
|
|
|
2683
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require UR; |
7
|
|
|
|
|
|
|
our $VERSION = "0.46"; # UR $VERSION; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
UR::Object::Type->define( |
10
|
|
|
|
|
|
|
class_name => 'UR::Value::HASH', |
11
|
|
|
|
|
|
|
is => ['UR::Value::PerlReference'], |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub __display_name__ { |
15
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
16
|
1
|
|
|
|
|
4
|
my $hash = $self->id; |
17
|
1
|
|
|
|
|
2
|
my @values; |
18
|
1
|
|
|
|
|
6
|
for my $key (sort keys %$hash) { |
19
|
13
|
50
|
|
|
|
17
|
next unless defined $hash->{$key}; |
20
|
13
|
50
|
|
|
|
24
|
push @values, "$key => '".( defined $hash->{$key} ? $hash->{$key} : '' ). "'"; |
21
|
|
|
|
|
|
|
} |
22
|
1
|
50
|
|
|
|
4
|
my $join = ( defined $_[0] ) ? $_[0] : ','; # Default join is a comma |
23
|
1
|
|
|
|
|
13
|
return join($join, @values); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub to_text { |
27
|
1
|
|
|
1
|
0
|
1
|
my $self = shift; |
28
|
1
|
|
|
|
|
3
|
my $hash = $self->id; |
29
|
1
|
|
|
|
|
3
|
my @tokens; |
30
|
1
|
|
|
|
|
6
|
for my $key (sort keys %$hash) { |
31
|
13
|
|
|
|
|
14
|
push @tokens, '-'.$key; |
32
|
13
|
100
|
66
|
|
|
38
|
next if not defined $hash->{$key} or $hash->{$key} eq ''; |
33
|
9
|
50
|
|
|
|
10
|
if ( my $ref = ref $hash->{$key} ) { |
34
|
0
|
0
|
|
|
|
0
|
if ( $ref ne 'ARRAY' ) { |
35
|
0
|
|
|
|
|
0
|
$self->warning_message("Can not convert hash to text. Cannot handle $ref for $key"); |
36
|
0
|
|
|
|
|
0
|
return; |
37
|
|
|
|
|
|
|
} |
38
|
0
|
|
|
|
|
0
|
push @tokens, @{$hash->{$key}}; |
|
0
|
|
|
|
|
0
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
9
|
|
|
|
|
11
|
push @tokens, $hash->{$key}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
1
|
50
|
|
|
|
3
|
my $join = ( defined $_[0] ) ? $_[0] : ' '; # Default join is a space |
45
|
1
|
|
|
|
|
9
|
return UR::Value::Text->get( join($join, @tokens)); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|