summaryrefslogtreecommitdiff
path: root/lib/Getopt/Dakkar/Role/Piece.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Getopt/Dakkar/Role/Piece.pm')
-rw-r--r--lib/Getopt/Dakkar/Role/Piece.pm22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/Getopt/Dakkar/Role/Piece.pm b/lib/Getopt/Dakkar/Role/Piece.pm
new file mode 100644
index 0000000..d981095
--- /dev/null
+++ b/lib/Getopt/Dakkar/Role/Piece.pm
@@ -0,0 +1,22 @@
+package Getopt::Dakkar::Role::Piece;
+use Getopt::Dakkar::Style qw(role);
+# VERSION
+# ABSTRACT: a piece
+
+has class => ( is => 'ro', isa => ClassName, default => 'Getopt::Dakkar::Stash' );
+has object => ( is => 'ro', isa => Object );
+has op => ( is => 'ro', isa => Str|CodeRef );
+
+sub make_stash($self,$argpack) {
+ if (my $o = $self->object) { return $o }
+
+ my $class = use_module($self->class);
+ if (my $from_argpack = $class->can('new_from_argpack')) {
+ return $class->$from_argpack($argpack);
+ }
+ else {
+ return $class->new();
+ }
+}
+
+requires 'parse';