.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Dancer::Config::Object 3pm" .TH Dancer::Config::Object 3pm "2023-02-10" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Dancer::Config::Object \- Access the config via methods instead of hashrefs .SH "VERSION" .IX Header "VERSION" version 1.3521 .SH "DESCRIPTION" .IX Header "DESCRIPTION" If \f(CW\*(C`strict_config\*(C'\fR is set to a true value in the configuration, the \&\f(CW\*(C`config()\*(C'\fR subroutine will return an object instead of a hashref. Instead of this: .PP .Vb 2 \& my $serializer = config\->{serializer}; \& my $username = config\->{auth}{username}; .Ve .PP You get this: .PP .Vb 2 \& my $serializer = config\->serializer; \& my $username = config\->auth\->username; .Ve .PP This helps to prevent typos. If you mistype a configuration name: .PP .Vb 1 \& my $pass = config\->auth\->pass; .Ve .PP An exception will be thrown, tell you it can't find the method name, but listing available methods: .PP .Vb 2 \& Can\*(Aqt locate config attribute "pass". \& Available attributes: password, username .Ve .PP If the hash key cannot be converted into a proper method name, you can still access it via a hash reference: .PP .Vb 1 \& my $some_value = config\->{\*(Aq99_bottles\*(Aq}; .Ve .PP And call methods on it, if possible: .PP .Vb 1 \& my $sadness = config\->{\*(Aq99_more_bottles\*(Aq}\->last_bottle; .Ve .PP Hash keys pointing to hash references will in turn have those \*(L"objectified\*(R". Arrays will still be returned as array references. However, hashrefs inside of the array refs may still have their keys allowed as methods: .PP .Vb 1 \& my $some_value = config\->some_list\->[1]\->host; .Ve .SH "METHOD NAME DEFINITION" .IX Header "METHOD NAME DEFINITION" We use the following regular expression to determine if a hash key qualifies as a method: .PP .Vb 1 \& /^[[:alpha:]_][[:word:]]*$/; .Ve .PP Note that this means \f(CW\*(C`naïve\*(C'\fR (note the dots over the i) can be a method name, but unless you \f(CW\*(C`use utf8;\*(C'\fR to declare that your source code is \s-1UTF\-8,\s0 you may have disappointing results calling \f(CW\*(C`config\->naïve\*(C'\fR. Further, depending on your version of Perl and the software to read your config file ... well, you get the idea. We recommend sticking with \s-1ASCII\s0 identifiers if you wish your code to be portable. .PP Patches/suggestions welcome. .SH "AUTHOR" .IX Header "AUTHOR" This module has been written by Alexis Sukrieh and others, see the \s-1AUTHORS\s0 file that comes with this distribution for details. .SH "LICENSE" .IX Header "LICENSE" This module is free software and is released under the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO" Dancer and Dancer::Config. .SH "AUTHOR" .IX Header "AUTHOR" Dancer Core Developers .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2010 by Alexis Sukrieh. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.