summaryrefslogtreecommitdiff
path: root/lib/Getopt/Dakkar/Role/Piece.pm
blob: d9810954d688824b4ac090bd4aff171c891d47d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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';