.\" 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 "Badger::Data 3pm" .TH Badger::Data 3pm "2023-08-28" "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 "NOTE" .IX Header "NOTE" This is being merged in from Template::TT3::Type. The documentation still refers to the old name and relates to TT-specific use. .SH "NAME" Badger::Data \- base class for data object .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& # defining a subclass data type \& package Badger::Data::Thing; \& use base \*(AqBadger::Data\*(Aq; \& \& our $METHODS = { \& wibble => \e&wibble, \& wobble => \e&wobble, \& }; \& \& sub wibble { \& my $self = shift; \& # some wibble code... \& } \& \& sub wobble { \& my $self = shift; \& # some wobble code... \& } .Ve .SH "PLEASE NOTE" .IX Header "PLEASE NOTE" This module is being merged in from the prototype \f(CW\*(C`Template\-TT3\*(C'\fR code. The implementation is subject to change and the documentation may be incomplete or incorrect in places. .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \f(CW\*(C`Badger::Data\*(C'\fR module implements a base class for the Badger::Data::Text, Badger::Data::List and Badger::Data::Hash data objects. .SH "METHODS" .IX Header "METHODS" The following methods are defined in addition to those inherited from Badger::Prototype and Badger::Base. .SS "init(\e%config)" .IX Subsection "init(%config)" Initialialisation method to handle any per-object initialisation. This is called by the \fBnew()\fR method inherited from Badger::Base . In this base class, the method simply copies all items in the \f(CW$config\fR hash array into the \f(CW$self\fR object. .SS "\fBclone()\fP" .IX Subsection "clone()" Create a copy of the current object. .PP .Vb 1 \& my $clone = $object\->clone(); .Ve .PP Additional named parameters can be provided. These are merged with the items defined in the parent object and passed to the cloned object's \fBinit()\fR method. .PP .Vb 1 \& my $clone = $object\->clone( g => 0.577 ); .Ve .SS "\fBmethods()\fP" .IX Subsection "methods()" Returns a reference to a hash array containing the content of the \&\f(CW$METHODS\fR package variable in the current class and any base classes. .PP .Vb 1 \& my $methods = $object\->methods; .Ve .SS "method($name)" .IX Subsection "method($name)" Returns a reference to a particular method from the hash reference returned by the \fBmethods()\fR method. .PP .Vb 1 \& my $method = $object\->method(\*(Aqref\*(Aq); .Ve .PP When called without any arguments, it returns a reference to the entire hash reference, as per \fBmethods()\fR. .PP .Vb 1 \& my $method = $object\->method\->{ foo }; .Ve .SS "metadata($name,$value)" .IX Subsection "metadata($name,$value)" This method provides access to an out-of-band (i.e. stored separately from the data itself) hash array of metadata for the data item. It returns a reference to a hash array when called without arguments. .PP .Vb 3 \& # fetch metadata hash and add an entry \& my $metadata = $data\->metadata; \& $metadata\->{ author } = \*(AqArthur Dent\*(Aq; \& \& # later... print the metadata \& print $data\->metadata\->{ author }; .Ve .PP It returns the value of an item in the metadata hash when called with a single argument. .PP .Vb 1 \& print $data\->metadata(\*(Aqauthor\*(Aq); .Ve .PP It sets the value of an item when called with two arguments. .PP .Vb 1 \& $data\->metadata( author => \*(AqFord Prefect\*(Aq ); .Ve .SS "\fBref()\fP" .IX Subsection "ref()" Returns the name of the object type, e.g. \f(CW\*(C`Template::TT3::Type\*(C'\fR, \&\f(CW\*(C`Template::TT3::Type::Text\*(C'\fR, Template::TT3::Type::List, etc., exactly as Perl's \f(CW\*(C`ref()\*(C'\fR function does. .SS "\fBdefined()\fP" .IX Subsection "defined()" Returns a true/false (\f(CW1\fR/\f(CW0\fR) value to indicate if the target data is defined. .SS "\fBundefined()\fP" .IX Subsection "undefined()" Returns a true/false (\f(CW1\fR/\f(CW0\fR) value to indicate if the target data is undefined. .SS "\fBtrue()\fP" .IX Subsection "true()" Returns a true/false (\f(CW1\fR/\f(CW0\fR) value to indicate if the target data has a true value (using by Perl's definition of what constitutes truth). .SS "\fBfalse()\fP" .IX Subsection "false()" Returns a true/false (\f(CW1\fR/\f(CW0\fR) value to indicate if the target data has a false value (using by Perl's definition of what constitutes truth). .SH "AUTHOR" .IX Header "AUTHOR" Andy Wardley .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 1996\-2008 Andy Wardley. All Rights Reserved. .PP This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "SEE ALSO." .IX Header "SEE ALSO." Template::TT3::Type::Text, Template::TT3::Type::List and Template::TT3::Type::Hash.