Skip to content

Commit

Permalink
rejigger building of v2-style prereqs
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbs committed Oct 3, 2013
1 parent 624a421 commit b285ab0
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions lib/Module/Faker/Dist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -221,33 +221,29 @@ has omitted_files => (
auto_deref => 1,
);

# old v1 style; should use 'prereqs' instead
has requires => (
is => 'ro',
isa => 'HashRef',
lazy => 1,
default => sub { {} },
auto_deref => 1,
);
around BUILDARGS => sub {
my ($orig, $self, @rest) = @_;
my $arg = $self->$orig(@rest);

confess "can't supply both requires and prereqs"
if $arg->{prereqs} && $arg->{requires};

if ($arg->{requires}) {
$arg->{prereqs} = {
runtime => { requires => delete $arg->{requires} }
};
}

return $arg;
};

# upgrade from 'requires' if necessary
has prereqs => (
is => 'ro',
isa => 'HashRef',
lazy_build => 1,
default => sub { {} },
auto_deref => 1,
);

sub _build_prereqs {
my ($self) = @_;
if ( keys %{$self->requires} ) {
return { runtime => { requires => { $self->requires } } };
}
else {
return {}
}
}

has _manifest_file => (
is => 'ro',
isa => 'Module::Faker::File',
Expand Down

0 comments on commit b285ab0

Please sign in to comment.