diff options
Diffstat (limited to 'lib/Config/Tree/Node/Section.pm')
-rw-r--r-- | lib/Config/Tree/Node/Section.pm | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/Config/Tree/Node/Section.pm b/lib/Config/Tree/Node/Section.pm index b9d0620..8fec46b 100644 --- a/lib/Config/Tree/Node/Section.pm +++ b/lib/Config/Tree/Node/Section.pm @@ -2,6 +2,8 @@ package Config::Tree::Node::Section; use parent 'Config::Tree::Node'; use strict; use warnings; +use Carp; +use Config::Tree::Node::Null; sub new { my $class = shift; @@ -36,8 +38,6 @@ sub delete { delete $self->{_subtree}{$key}; } -sub is_leaf { 0 } - sub merge { my ($self, $other) = @_; while (my ($k, $v) = each %{$other->subtree}) { @@ -57,4 +57,20 @@ sub merge { } } +sub as_string { '(section)' } + +our $AUTOLOAD; + +sub AUTOLOAD { + my $self = shift; + my $key = $AUTOLOAD; + $key =~ s/.*:://; + if ($key =~ s/^([A-Z])(.*)/\l$1$2/) { + $key =~ s/__/-/g; + return $self->subtree($self->{_ci} ? lc($key) : $key) + // new Config::Tree::Node::Null; + } + confess "Can't locate method $AUTOLOAD"; +} + 1; |