/usr/share/perl5/Config/MVP/Sequence.pm is in libconfig-mvp-perl 2.200006-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | package Config::MVP::Sequence;
{
$Config::MVP::Sequence::VERSION = '2.200006';
}
use Moose 0.91;
# ABSTRACT: an ordered set of named configuration sections
use Tie::IxHash;
use Config::MVP::Error;
use Config::MVP::Section;
use Moose::Util::TypeConstraints ();
# This is a private attribute and should not be documented for futzing-with,
# most likely. -- rjbs, 2009-08-09
has sections => (
isa => 'HashRef[Config::MVP::Section]',
reader => '_sections',
init_arg => undef,
default => sub {
tie my %section, 'Tie::IxHash';
return \%section;
},
);
has assembler => (
is => 'ro',
isa => Moose::Util::TypeConstraints::class_type('Config::MVP::Assembler'),
weak_ref => 1,
predicate => '_assembler_has_been_set',
reader => '_assembler',
writer => '__set_assembler',
);
sub _set_assembler {
my ($self, $assembler) = @_;
Config::MVP::Error->throw("can't alter Config::MVP::Sequence's assembler")
if $self->assembler;
$self->__set_assembler($assembler);
}
sub assembler {
my ($self) = @_;
return undef unless $self->_assembler_has_been_set;
my $assembler = $self->_assembler;
unless (defined $assembler) {
Config::MVP::Error->throw("can't access sequences's destroyed assembler")
}
return $assembler;
}
has is_finalized => (
is => 'ro',
isa => 'Bool',
traits => [ 'Bool' ],
init_arg => undef,
default => 0,
handles => { finalize => 'set' },
);
sub add_section {
my ($self, $section) = @_;
Config::MVP::Error->throw("can't add sections to finalized sequence")
if $self->is_finalized;
my $name = $section->name;
confess "already have a section named $name" if $self->_sections->{ $name };
$section->_set_sequence($self);
if (my @names = $self->section_names) {
my $last_section = $self->section_named( $names[-1] );
$last_section->finalize unless $last_section->is_finalized;
}
$self->_sections->{ $name } = $section;
}
sub delete_section {
my ($self, $name) = @_;
Config::MVP::Error->throw("can't delete sections from finalized sequence")
if $self->is_finalized;
my $sections = $self->_sections;
return unless exists $sections->{ $name };
$sections->{ $name }->_clear_sequence;
return delete $sections->{ $name };
}
sub section_named {
my ($self, $name) = @_;
my $sections = $self->_sections;
return unless exists $sections->{ $name };
return $sections->{ $name };
}
sub section_names {
my ($self) = @_;
return keys %{ $self->_sections };
}
sub sections {
my ($self) = @_;
return values %{ $self->_sections };
}
no Moose;
1;
__END__
=pod
=head1 NAME
Config::MVP::Sequence - an ordered set of named configuration sections
=head1 VERSION
version 2.200006
=head1 DESCRIPTION
A Config::MVP::Sequence is an ordered set of configuration sections, each of
which has a name unique within the sequence.
For the most part, you can just consult L<Config::MVP> to understand what this
class is and how it's used.
=head1 ATTRIBUTES
=head2 is_finalized
This attribute is true if the sequence has been marked finalized, which will
prevent any changes (via methods like C<add_section> or C<delete_section>). It
can be set with the C<finalize> method.
=head1 METHODS
=head2 add_section
$sequence->add_section($section);
This method adds the given section to the end of the sequence. If the sequence
already contains a section with the same name as the new section, an exception
will be raised.
=head2 delete_section
my $deleted_section = $sequence->delete_section( $name );
This method removes a section from the sequence and returns the removed
section. If no section existed, the method returns false.
=head2 section_named
my $section = $sequence->section_named( $name );
This method returns the section with the given name, if one exists in the
sequence. If no such section exists, the method returns false.
=head2 section_names
my @names = $sequence->section_names;
This method returns a list of the names of the sections, in order.
=head2 sections
my @sections = $sequence->sections;
This method returns the section objects, in order.
=head1 AUTHOR
Ricardo Signes <rjbs@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|