README
1NAME
2 accessors::fast - Compiletime accessors using Class::Accessor::Fast
3
4VERSION
5 Version 0.03
6
7SYNOPSIS
8 package My::Simple::Package;
9 use accessors::fast qw(field1 field2);
10
11 # constructor is private, redefine only init;
12 sub init {
13 my $self = shift;
14 my %args = @_;
15 $self->field1($args{arg1});
16 }
17
18 package main;
19 my $o = My::Simple::Package->new( arg1 => 'some value' );
20 print $o->field1; # some value
21
22 for ($o->field_list) {
23 printf "object have field %s with value %s\n", $_, $o->$_;
24 }
25
26DESCRIPTION
27 This module was created as an alternative to "use fields", and uses
28 Class::Accessor::Fast as a base
29
30 Creates accessors at compiletime
31
32 Have own default "new" method: it creates object as a blessed hash, then
33 locks keys to defined field list, and invoke "init". So, recommended
34 usage inside packages, is access by hash keys (it's 3 times faster then
35 accessor). Since keys are locked, you will not suffer from
36 autovivification. Public interface recommended to be documented as
37 accessors.
38
39 Uses Class::C3
40
41METHODS
42 All methods inherited from Class::Accessors::Fast. Own methods defined
43 below
44
45 new( ARGS )
46 Creates blessed hash, locks it keys to current fields of this package,
47 and invoke "init" method with "ARGS"
48
49 init( ARGS )
50 Recommended to redefine in subclasses. Will be invoked by inherited
51 "new"
52
53 field_list
54 Since this module keeps information about object fields, it can return
55 it.
56
57 for ($o->field_list) {
58 printf "%s: %s\n",$_,$o->$_;
59 }
60
61FEATURES
62 This module uses constant::def, so it behaviour could be affected by
63 constant::abs
64
65 TIE [ = 0 ]
66 Use tied hash, instead of Hash::Util"::lock_keys". Much more slower, but
67 could help during development.
68
69 Could be enabled by
70
71 # your main program/main.pl
72 use constant::abs 'accessors::fast::TIE' => 1;
73
74 CONFESS [ = 0 ]
75 use Carp::confess instead of croak on error conditions
76
77 Could be enabled by
78
79 # your main program/main.pl
80 use constant::abs 'accessors::fast::CONFESS' => 1;
81
82 warnings
83 This module uses warnings::register. So, warnings from it could be
84 disabled by
85
86 no warnings 'accessors::fast';
87
88BUGS
89 None known
90
91COPYRIGHT & LICENSE
92 Copyright 2009 Mons Anderson.
93
94 This program is free software; you can redistribute it and/or modify it
95 under the same terms as Perl itself.
96
97AUTHOR
98 Mons Anderson, <mons@cpan.org>
99
100