summaryrefslogtreecommitdiffstats
path: root/lib/IM/Engine/Plugin/Commands/Trait/Method/Formatted.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IM/Engine/Plugin/Commands/Trait/Method/Formatted.pm')
-rw-r--r--lib/IM/Engine/Plugin/Commands/Trait/Method/Formatted.pm23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/IM/Engine/Plugin/Commands/Trait/Method/Formatted.pm b/lib/IM/Engine/Plugin/Commands/Trait/Method/Formatted.pm
new file mode 100644
index 0000000..82dcd04
--- /dev/null
+++ b/lib/IM/Engine/Plugin/Commands/Trait/Method/Formatted.pm
@@ -0,0 +1,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;