Commit | Line | Data |
ddccc6a2 |
1 | package Reaction::UI::ViewPort::Field::RelatedObject; |
7adfd53f |
2 | |
3 | use Reaction::Class; |
4 | use Scalar::Util 'blessed'; |
7b5e71ad |
5 | use MooseX::Types::Moose qw/Str/; |
7adfd53f |
6 | |
81393881 |
7 | use namespace::clean -except => [ qw(meta) ]; |
8 | extends 'Reaction::UI::ViewPort::Field'; |
7adfd53f |
9 | |
81393881 |
10 | has value_map_method => ( |
7b5e71ad |
11 | isa => Str, is => 'ro', required => 1, default => sub { 'display_name' }, |
81393881 |
12 | ); |
13 | |
14 | around _value_string_from_value => sub { |
15 | my $orig = shift; |
16 | my $self = shift; |
17 | my $meth = $self->value_map_method; |
18 | return $self->$orig(@_)->$meth; |
7adfd53f |
19 | }; |
20 | |
81393881 |
21 | __PACKAGE__->meta->make_immutable; |
22 | |
23 | |
7adfd53f |
24 | 1; |