Kentaro Kuribayashi > Class-AutoAccess-Deep-0.02 > Class::AutoAccess::Deep

Download:
Class-AutoAccess-Deep-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

Class::AutoAccess::Deep - automatically creates the accessors reach deep inside the field

SYNOPSIS ^

  package MyClass;

  # inherit Class::AutoAccess::Deep and that's all
  use base qw(Class::AutoAccess::Deep);

  sub to_check {
      # write your own processing code...
  }

  package main;

  $data = {
      foo      => undef,
      bar      => {
          baz  => undef,
      },
      to_check => undef,
  };

  my $obj = MyClass->new($data);

  # now, you can access the fields as described below
  $obj->foo('new value');        # set "new value"
  my $foo = $obj->foo;           # get "new value"

  # you can access the field chain deeply
  # by joining field name with '->'
  $obj->bar->baz('other value'); # set "other value"
  my $bar_baz = $obj->bar->baz;  # get "other value"

  # your own method called correctly
  my $value = $obj->to_check;

DESCRIPTION ^

Class::AutoAccess::Deep is the base class for automated accessors implementation. You can access deep inside the object fields to call the method named by joining the object field name with '->' operator.

METHOD ^

new ( \%fields )

  my $obj = MyClass->new(\%fields);

Creates and returns new object. It takes a hashref which is used to initialize the object. If you don't like it, override it.

EXCEPTION ^

When you attempt to access the undefined field, Class::AutoAccess::Deep object throws exception using Carp::croak.

TODO ^

ACKNOWLEDGEMENTS ^

AUTHOR ^

Kentaro Kuribayashi, <kentaro@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (C) 2005 by Kentaro Kuribayashi

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: