annotate Lib/IMPL/Class/Property/Direct.pm @ 229:47f77e6409f7

heavily reworked the resource model of the web application: *some ResourcesContraact functionality moved to Resource +Added CustomResource *Corrected action handlers
author sergey
date Sat, 29 Sep 2012 02:34:47 +0400
parents 4d0e1962161c
children 6253872024a4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
1 package IMPL::Class::Property::Direct;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
3
165
76515373dac0 Added Class::Template,
wizard
parents: 155
diff changeset
4 use parent qw(Exporter IMPL::Object::Accessor IMPL::Class::Property::Base);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
5 our @EXPORT = qw(_direct);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
6
55
609b59c9f03c Web application
wizard
parents: 52
diff changeset
7 require IMPL::Object::List;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
8 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
9 require IMPL::Exception;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
10
179
b3d91ff7aea9 minor changes
sourcer
parents: 165
diff changeset
11 __PACKAGE__->mk_accessors( qw(ExportField) );
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
12
60
b0c068da93ac Lazy activation for the configuration objects (final concept)
wizard
parents: 59
diff changeset
13 sub factoryParams {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
14 $_[0]->SUPER::factoryParams, qw($field);
60
b0c068da93ac Lazy activation for the configuration objects (final concept)
wizard
parents: 59
diff changeset
15 }
59
0f3e369553bd Rewritten property implementation (probably become slower but more flexible)
wizard
parents: 55
diff changeset
16
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 179
diff changeset
17 my $default = __PACKAGE__->new({ExportField => 1});
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 179
diff changeset
18
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
19 sub _direct($) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
20 my ($prop_info) = @_;
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 179
diff changeset
21 $prop_info->Implementor( $default );
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
22 return $prop_info;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
23 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
24
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
25
59
0f3e369553bd Rewritten property implementation (probably become slower but more flexible)
wizard
parents: 55
diff changeset
26 sub GenerateGet {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
27 'return ($this->{$field});';
59
0f3e369553bd Rewritten property implementation (probably become slower but more flexible)
wizard
parents: 55
diff changeset
28 }
0f3e369553bd Rewritten property implementation (probably become slower but more flexible)
wizard
parents: 55
diff changeset
29
0f3e369553bd Rewritten property implementation (probably become slower but more flexible)
wizard
parents: 55
diff changeset
30 sub GenerateSet {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
31 'return ($this->{$field} = $_[0])';
59
0f3e369553bd Rewritten property implementation (probably become slower but more flexible)
wizard
parents: 55
diff changeset
32 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
33
59
0f3e369553bd Rewritten property implementation (probably become slower but more flexible)
wizard
parents: 55
diff changeset
34 sub GenerateSetList {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
35 'return(
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
36 wantarray ?
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
37 @{ $this->{$field} = IMPL::Object::List->new(
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
38 (@_ == 1 and UNIVERSAL::isa($_[0], \'ARRAY\') ) ? $_[0] : [@_]
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
39 )} :
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
40 ($this->{$field} = IMPL::Object::List->new(
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
41 (@_ == 1 and UNIVERSAL::isa($_[0], \'ARRAY\') ) ? $_[0] : [@_]
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
42 ))
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
43 );';
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
44 }
59
0f3e369553bd Rewritten property implementation (probably become slower but more flexible)
wizard
parents: 55
diff changeset
45
0f3e369553bd Rewritten property implementation (probably become slower but more flexible)
wizard
parents: 55
diff changeset
46 sub GenerateGetList {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
47 'return(
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
48 wantarray ?
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
49 @{ $this->{$field} ?
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
50 $this->{$field} :
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
51 ( $this->{$field} = IMPL::Object::List->new() )
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
52 } :
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
53 ( $this->{$field} ?
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
54 $this->{$field} :
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
55 ( $this->{$field} = IMPL::Object::List->new() )
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
56 )
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
57 );';
59
0f3e369553bd Rewritten property implementation (probably become slower but more flexible)
wizard
parents: 55
diff changeset
58 }
0f3e369553bd Rewritten property implementation (probably become slower but more flexible)
wizard
parents: 55
diff changeset
59
0f3e369553bd Rewritten property implementation (probably become slower but more flexible)
wizard
parents: 55
diff changeset
60 sub RemapFactoryParams {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
61 my ($self,$propInfo) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
62
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
63 return $self->SUPER::RemapFactoryParams($propInfo),$self->FieldName($propInfo);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
64 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
65
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
66 sub Make {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
67 my ($self,$propInfo) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
68
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
69 $self->SUPER::Make($propInfo);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
70
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
71 {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
72 no strict 'refs';
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
73 if (ref $self and $self->ExportField) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
74 my $field = $self->FieldName($propInfo);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
75 *{$propInfo->Class.'::'.$propInfo->Name} = \$field;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
76 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
77 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
78 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
79
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
80 sub FieldName {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
81 my ($self,$propInfo) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
82
179
b3d91ff7aea9 minor changes
sourcer
parents: 165
diff changeset
83 my ($class,$name) = $propInfo->get( qw(Class Name) );
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
84 (my $field = "${class}_$name") =~ s/::/_/g;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
85 return $field;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
86 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
87
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
88 1;