The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Class::Data::Inheritable::Translucent - Inheritable, overridable, translucent class data / object attributes

SYNOPSIS

  package Foo;
  use base 'Class::Data::Inheritable::Translucent';

  Foo->mk_translucent("bar");
  Foo->bar("baz");

  $obj = Foo->new;

  print $obj->bar; # prints "baz"

  $obj->bar("whatever");

  print $obj->bar; # prints "whatever"
  print Foo->bar;  # prints "baz"

  $obj->bar(undef);

  print $obj->bar; # prints "baz"

DESCRIPTION

This module is derived from Class::Data::Inheritable, and is largely the same, except the class data accessors double as translucent object attributes.

Object data, by default, is stored in $obj->{$attribute}. See the ->attrs method, explained below, on how to change that.

METHODS

mk_translucent

Creates inheritable class data / translucent instance attributes

attrs

This method is called by the generated accessors and, by default, simply returns the object that called it, which should be a hash reference for storing object attributes. If your objects are not hashrefs, or you wish to store your object attributes in a different location, eg. $obj->{attrs}, you should override this method. Class::Data::Inheritable::Translucent stores object attributes in $obj->attrs->{$attribute}.

AUTHOR

Ryan McGuigan, <ryan@cardweb.com>

Derived from Class::Data::Inheritable, originally by Damian Conway

ACKNOWLEDGEMENTS

Thanks to Damian Conway for Class::Data::Inheritable

COPYRIGHT & LICENSE

Copyright 2005 Ryan McGuigan, all rights reserved.

mk_translucent is derived from mk_classdata from Class::Data::Inheritable, Copyright Damian Conway and Michael G Schwern, licensed under the terms of the Perl Artistic License.

This program is free software; It may be used, redistributed and/or modified under the terms of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html)

BUGS

Please report any bugs or feature requests to ryan@cardweb.com.

SEE ALSO

  • Class::Data::Inheritable

  • perltooc - Tom's OO Tutorial for Class Data in Perl - a pretty nice Class Data tutorial for Perl

  • The source. It's quite short, and simple enough.