diff options
Diffstat (limited to 'lib/SlackBuild/Request.pm')
-rw-r--r-- | lib/SlackBuild/Request.pm | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/SlackBuild/Request.pm b/lib/SlackBuild/Request.pm index 4ae81d3..3876b56 100644 --- a/lib/SlackBuild/Request.pm +++ b/lib/SlackBuild/Request.pm @@ -107,6 +107,7 @@ my %attributes = ( }, build => { type => 'SCALAR', + default => 1, }, slackbuild_uri => { type => 'SCALAR', @@ -163,7 +164,7 @@ my %generics = ( }, set => sub { my ($self, $attr, $value, $strat) = @_; - croak "hashref expected" unless ref($value) eq 'HASH'; + croak "hashref expected when setting $attr" unless ref($value) eq 'HASH'; if (defined($self->{$attr}) && defined($strat) && $strat ne 'keep') { if ($strat eq 'merge') { @@ -349,6 +350,15 @@ sub load { croak "unrecognized request type"; } +sub merge { + my ($self, $other) = @_; + foreach my $attr (keys %attributes) { + unless (defined($self->{$attr})) { + $self->${\ "set_$attr"}($other->${\ $attr}); + } + } +} + =head1 STRING REPRESENTATION When used is string context, objects of this class are represented as @@ -450,7 +460,8 @@ sub set_prereq { unless (__PACKAGE__->can($attr)) { *{ __PACKAGE__ . '::' . $attr } = sub { my $self = shift; - return $self->${ \ $generics{$descr->{type}}{get} }($attr); + return $self->${ \ $generics{$descr->{type}}{get} }($attr) + || $descr->{default}; } } unless (__PACKAGE__->can("set_$attr")) { |