Class::AccessorMaker::Private - generate private accessor method with default values.



NAME

Class::AccessorMaker::Private - generate private accessor method with default values.


DESCRIPTION

For further SYNOPSIS, DESCRIPTION and PITFALLS please read the perldoc of Class::AccessorMaker.

This 'AccessorMaker' makes you private methods. Actually the methods are accessible from just about anywhere you like em to, but the data structure that lies beneath it all is hidden in a far away place. This forces the users of your object to actually use the acccessor methods, instead of trying to temper with your objects internals.


BUT I WANT TO ...

test the value of my accessor or perhaps even slightly alter it...

Too bad, Class:AccessorMaker::Private does not do this for you. You will have to write your own accessor method. Ah, too bad again, AccessorMaker::Private does not even give your object reachable data, but the object self is a blessed hash, be it very empty, so you can use that...

But if you wish to use global-data for it, be my guest, not that I advice it, cause it is generally a bad idea to use global data, and if you use it, you do not even need accessor methods, right?

an example:

  sub seperator {
    my ($self, $value) = @_;
    # set the default value.
    $self->{seperator} = '$$' if !exists $self->{seperator}
    if ( $#_ > 0 ) {
      $self->{seperator} = quotemeta($value);
      return $self;
    }
    return $self->{seperator};
  }

I think I can skip a code explanation, right?


AUTHOR

Hartog 'Sinister' de Mik <hartog@2organize.com>


COPYRIGHT

Copyright (c) 2002 Hartog C. de Mik. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

 Class::AccessorMaker::Private - generate private accessor method with default values.