This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Module-Build to CPAN version 0.4201
[perl5.git] / cpan / Module-Build / lib / Module / Build / Config.pm
CommitLineData
77e96e88
RGS
1package Module::Build::Config;
2
3use strict;
7a827510 4use vars qw($VERSION);
d320cf40 5$VERSION = '0.4201';
7a827510 6$VERSION = eval $VERSION;
77e96e88
RGS
7use Config;
8
9sub new {
10 my ($pack, %args) = @_;
11 return bless {
12 stack => {},
13 values => $args{values} || {},
14 }, $pack;
15}
16
17sub get {
18 my ($self, $key) = @_;
19 return $self->{values}{$key} if ref($self) && exists $self->{values}{$key};
20 return $Config{$key};
21}
22
23sub set {
24 my ($self, $key, $val) = @_;
25 $self->{values}{$key} = $val;
26}
27
28sub push {
29 my ($self, $key, $val) = @_;
30 push @{$self->{stack}{$key}}, $self->{values}{$key}
31 if exists $self->{values}{$key};
32 $self->{values}{$key} = $val;
33}
34
35sub pop {
36 my ($self, $key) = @_;
37
38 my $val = delete $self->{values}{$key};
39 if ( exists $self->{stack}{$key} ) {
40 $self->{values}{$key} = pop @{$self->{stack}{$key}};
41 delete $self->{stack}{$key} unless @{$self->{stack}{$key}};
42 }
43
44 return $val;
45}
46
47sub values_set {
48 my $self = shift;
49 return undef unless ref($self);
50 return $self->{values};
51}
52
53sub all_config {
54 my $self = shift;
55 my $v = ref($self) ? $self->{values} : {};
56 return {%Config, %$v};
57}
58
591;