summaryrefslogtreecommitdiffstats
path: root/lib/IM/Engine/Plugin/Commands/Trait/Method/Formatted.pm
blob: 82dcd04759ee4294cf780acd6db911c2c9b09b4b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package IM::Engine::Plugin::Commands::Trait::Method::Formatted;
use Moose::Role;
use Scalar::Util qw(reftype);

has formatter => (
    is      => 'rw',
    isa     => 'CodeRef',
    default => sub { sub {
        Carp::cluck "no formatter specified!";
        return @_;
    } },
);

sub _munge_formatter {
    my $self = shift;
    my ($format) = @_;
    return $format if reftype($format) eq 'CODE';
    return $self->associated_metaclass->formatter_for($format);
}

no Moose::Role;

1;