\r
require XML::Simple;\r
XML::Simple->import;\r
- my $config = XMLin( $file, ForceArray => [ qw( component model view controller ) ] );\r
+ my $config = XMLin( \r
+ $file, \r
+ ForceArray => [ qw( component model view controller ) ],\r
+ );\r
\r
- return $config;\r
+ return $class->_coerce($config);\r
+}\r
+\r
+sub _coerce {\r
+ # coerce the XML-parsed config into the correct format\r
+ my $class = shift;\r
+ my $config = shift;\r
+ my $out;\r
+ for my $k (keys %$config) {\r
+ my $ref = $config->{$k};\r
+ my $name = ref $ref ? delete $ref->{name} : undef;\r
+ if (defined $name) {\r
+ $out->{$k}->{$name} = $ref; \r
+ } else {\r
+ $out->{$k} = $ref;\r
+ }\r
+ }\r
+ $out;\r
}\r
\r
=head1 AUTHOR\r
\r
=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
\r
+=item * Joel Bernstein E<lt>rataxis@cpan.orgE<gt>\r
+\r
=back\r
\r
=head1 COPYRIGHT AND LICENSE\r
\r
=cut\r
\r
-1;
\ No newline at end of file
+1;\r