Class::Data::Inheritable - Online Linux Manual PageSection : 3
Updated : 2022-01-21
Source : perl v5.34.0
Note : User Contributed Perl Documentation

NAMEClass::Data::Inheritable − Inheritable, overridable class data

SYNOPSIS​ package Stuff; ​ use base qw(Class::Data::Inheritable); ​ ​ # Set up DataFile as inheritable class data. ​ Stuff−>mk_classdata('DataFile'); ​ ​ # Declare the location of the data file for this class. ​ Stuff−>DataFile('/etc/stuff/data'); ​ ​ # Or, all in one shot: ​ Stuff−>mk_classdata(DataFile => '/etc/stuff/data');

DESCRIPTIONClass::Data::Inheritable is for creating accessor/mutators to class data. That is, if you want to store something about your class as a whole (instead of about a single object). This data is then inherited by your subclasses and can be overridden. For example: ​ Pere::Ubu−>mk_classdata('Suitcase'); will generate the method Suitcase() in the class Pere::Ubu. This new method can be used to get and set a piece of class data. ​ Pere::Ubu−>Suitcase('Red'); ​ $suitcase = Pere::Ubu−>Suitcase; The interesting part happens when a class inherits from Pere::Ubu: ​ package Raygun; ​ use base qw(Pere::Ubu); ​ ​ # Raygun's suitcase is Red. ​ $suitcase = Raygun−>Suitcase; Raygun inherits its Suitcase class data from Pere::Ubu. Inheritance of class data works analogous to method inheritance. As long as Raygun does not override its inherited class data (by using ​Suitcase() to set a new value) it will continue to use whatever is set in Pere::Ubu and inherit further changes: ​ # Both Raygun's and Pere::Ubu's suitcases are now Blue ​ Pere::Ubu−>Suitcase('Blue'); However, should Raygun decide to set its own Suitcase() it has now ​overridden Pere::Ubu and is on its own, just like if it had overridden a method: ​ # Raygun has an orange suitcase, Pere::Ubu's is still Blue. ​ Raygun−>Suitcase('Orange'); Now that Raygun has overridden Pere::Ubu further changes by Pere::Ubu no longer effect Raygun. ​ # Raygun still has an orange suitcase, but Pere::Ubu is using Samsonite. ​ Pere::Ubu−>Suitcase('Samsonite');

Methods

mk_classdata​ Class−>mk_classdata($data_accessor_name); ​ Class−>mk_classdata($data_accessor_name => $value); This is a class method used to declare new class data accessors. A new accessor will be created in the Class using the name from ​$data_accessor_name, and optionally initially setting it to the given value. To facilitate overriding, mk_classdata creates an alias to the accessor, _field_accessor(). So Suitcase() would have an alias ​_Suitcase_accessor() that does the exact same thing as Suitcase(). This is useful if you want to alter the behavior of a single accessor yet still get the benefits of inheritable class data. For example. ​ sub Suitcase { ​ my($self) = shift; ​ warn "Fashion tragedy" if @_ and $_[0] eq 'Plaid'; ​ ​ $self−>_Suitcase_accessor(@_); ​ }

AUTHOROriginal code by Damian Conway. Maintained by Michael G Schwern until September 2005. Now maintained by Tony Bowden.

BUGS and QUERIESPlease direct all correspondence regarding this module to:
  bug−Class−Data−Inheritable@rt.cpan.org

COPYRIGHT and LICENSECopyright (c) 2000−2005, Damian Conway and Michael G Schwern. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.

SEE ALSOperltooc has a very elaborate discussion of class data in Perl.
0
Johanes Gumabo
Data Size   :   12,440 byte
man-Class::Data::Inheritable.3pmBuild   :   2024-12-29, 07:25   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   3 / 259,213
Visitor ID   :     :  
Visitor IP   :   18.222.161.57   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.29
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.

ERROR : Need New Coding :         (parse_manual_page_|252|Class::Data::Inheritable.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\| )         (htmlprn|149|Class::Data::Inheritable.3pm|36/37|.el══─{─══. ds --  —  |.el══─{─══. ds -- \|\(em\| )         (parse_manual_page_|252|Class::Data::Inheritable.3pm|43|br══─}─══|'br══─}─══ )         (htmlprn|149|Class::Data::Inheritable.3pm|43|'br══─}─══ |'br══─}─══ )