Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
remove custom fields when coercing to resources type
  • Loading branch information
haarg committed Jan 27, 2015
1 parent 3e017fb commit 3f783f9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/MetaCPAN/Types/Internal.pm
Expand Up @@ -122,12 +122,22 @@ subtype Resources,
];

coerce Resources, from HashRef, via {
my $r = $_;
return {
map { $_ => $r->{$_} }
grep { defined $r->{$_} }
qw(license homepage bugtracker repository)
};
my $r = $_;
my $resources = {};
for my $field (qw(license homepage bugtracker repository)) {
my $val = $r->{$field};
if ( !defined $val ) {
next;
}
elsif ( !ref $val ) {
}
elsif ( ref $val eq 'HASH' ) {
$val = {%$val};
delete @{$val}{ grep /^x_/, keys %$val };
}
$resources->{$field} = $val;
}
return $resources;
};

class_type 'CPAN::Meta';
Expand Down

0 comments on commit 3f783f9

Please sign in to comment.