File Coverage

blib/lib/Rose/HTMLx/Form/Related/RelInfo.pm
Criterion Covered Total %
statement 18 35 51.4
branch 0 6 0.0
condition n/a
subroutine 6 9 66.6
pod 3 3 100.0
total 27 53 50.9


line stmt bran cond sub pod time code
1             package Rose::HTMLx::Form::Related::RelInfo;
2 1     1   8 use strict;
  1         1  
  1         42  
3 1     1   6 use warnings;
  1         2  
  1         32  
4 1     1   5 use base qw( Rose::Object );
  1         1  
  1         158  
5             use Rose::Object::MakeMethods::Generic (
6 1         103 'scalar --get_set' => [
7             qw( name type method label
8             object_class foreign_class foreign_column
9             map_from map_to map_class map_to_column map_from_column
10             cmap controller controller_class app
11             map_class_controller_class
12             )
13             ],
14 1     1   6 );
  1         11  
15 1     1   11362 use Carp;
  1         2  
  1         85  
16 1     1   193 use Scalar::Util;
  1         4  
  1         316  
17              
18             our $VERSION = '0.24';
19              
20             =head1 NAME
21              
22             Rose::HTMLx::Form::Related::RelInfo - relationship summary
23              
24             =head1 DESCRIPTION
25              
26             Objects of this class are get/set from the various relationship
27             methods in Metadata. See Rose::HTMLx::Form::Related::Metadata
28             init_relationships().
29              
30             =head1 METHODS
31              
32             These are all get/set methods.
33              
34             =head2 app
35              
36             =head2 name
37              
38             =head2 type
39              
40             =head2 method
41              
42             =head2 label
43              
44             =head2 object_class
45              
46             =head2 foreign_class
47              
48             =head2 foreign_column
49              
50             =head2 map_from
51              
52             =head2 map_to
53              
54             =head2 map_class
55              
56             =head2 map_to_column
57              
58             =head2 map_from_column
59              
60             =head2 map_class_controller_class
61              
62             =head2 cmap
63              
64             =head2 controller
65              
66             =head2 controller_class
67              
68             =cut
69              
70             =head2 get_controller
71              
72             Returns controller() or fetches and caches a controller instance based
73             on app().
74              
75             =cut
76              
77             sub get_controller {
78 0     0 1   my $self = shift;
79 0 0         return $self->controller if defined $self->controller;
80 0           my $c = $self->app->controller( $self->controller_class );
81 0           $self->controller($c);
82 0           return $c;
83             }
84              
85             =head2 foreign_column_for( I )
86              
87             Returns the name of the foreign column related to I.
88             Shortcut for looking up items in cmap().
89              
90             =cut
91              
92             sub foreign_column_for {
93 0     0 1   my $self = shift;
94 0           my $name = shift;
95 0 0         if ( ref( $self->foreign_column ) ) {
96 0           return $self->foreign_column->{$name};
97             }
98             else {
99 0           return $self->foreign_column;
100             }
101             }
102              
103             =head2 as_hash
104              
105             Returns all non-blessed values in a single hashref. Suitable for debugging.
106              
107             =cut
108              
109             sub as_hash {
110 0     0 1   my $self = shift;
111 0           my %hash;
112 0           for my $key ( keys %$self ) {
113 0           my $value = $self->$key;
114 0 0         if ( !Scalar::Util::blessed($value) ) {
115 0           $hash{$key} = $value;
116             }
117             }
118 0           return \%hash;
119             }
120              
121             1;
122              
123             __END__