Line # Revision Author
1 3 ahitrov@rambler.ru package @NAME@::State;
2
3 use strict;
4 use warnings 'all';
5 use vars qw($AUTOLOAD);
6
7
8 sub new {
9 my ($proto) = @_;
10 my $class = ref($proto) || $proto;
11 my $self = {};
12 bless $self, $class;
13
14 # ������� ������������ �������
15 # $self->{db_type} = 'remote';
16 # $self->{db_keepalive} = 0;
17 # $self->{db_host} = '';
18 # $self->{db_name} = '';
19 # $self->{db_user} = '';
20 # $self->{db_password} = '';
21 # $self->{db_port} = '';
22
23 $self->_init_();
24 $self;
25 }
26
27 sub info {
28 my $self = shift;
29 return unless ref $self;
30
31 for (sort keys %{$self->{attributes}}) {
32 my $la = length $_;
33 warn "\t$_".("\t" x (2-int($la/8))).": $self->{$_}\n";
34 }
35 }
36
37 sub _init_ {
38 my $self = shift;
39
40 # ������� ������������ �������
41 $self->{attributes}->{$_} = 'SCALAR' for qw(
42 # db_type
43 # db_keepalive
44 # db_host
45 # db_port
46 # db_name
47 # db_user
48 # db_password
49 );
50 }
51
52 sub AUTOLOAD {
53 my $self = shift;
54 my $attribute = $AUTOLOAD;
55
56 $attribute =~ s/.*:://;
57 return unless $attribute =~ /[^A-Z]/; # ��������� ������ ���� DESTROY
58
59 if (!exists $self->{attributes}->{$attribute}) {
60 warn "Contenido Error (@NAME@::State): ����� ������, ��� �������� �� ���������� ��������������� ��������: ->$attribute()\n";
61 return;
62 }
63
64 $self->{$attribute} = shift @_ if $#_>=0;
65 $self->{$attribute};
66 }
67
68 1;