Commit | Line | Data |
f29e9b6f |
1 | package App::IdiotBox::Clonable; |
2 | |
3 | use Moo::Role; |
4 | |
5 | sub clone { |
6 | my $obj = shift; |
7 | |
8 | my $class = ref $obj; |
9 | |
10 | my %copy; |
11 | |
12 | for my $f ($obj->fields) { |
13 | $copy{$f} = $obj->$f, |
14 | }; |
15 | |
16 | return bless \%copy, $class; |
17 | } |
18 | |
19 | 1; |