Mercurial > pub > Impl
comparison Lib/IMPL/Object/Autofill.pm @ 278:4ddb27ff4a0b
core refactoring
author | cin |
---|---|
date | Mon, 04 Feb 2013 02:10:37 +0400 |
parents | 6253872024a4 |
children |
comparison
equal
deleted
inserted
replaced
277:6585464c4664 | 278:4ddb27ff4a0b |
---|---|
1 package IMPL::Object::Autofill; | 1 package IMPL::Object::Autofill; |
2 use strict; | 2 use strict; |
3 use IMPL::Class::Property; | 3 |
4 use IMPL::Const qw(:access); | |
4 | 5 |
5 sub CTOR { | 6 sub CTOR { |
6 my $this = shift; | 7 my $this = shift; |
7 no strict 'refs'; | 8 no strict 'refs'; |
8 | 9 |
49 sub _impl_object_autofill { | 50 sub _impl_object_autofill { |
50 my (\$this,\$fields) = \@_; | 51 my (\$this,\$fields) = \@_; |
51 HEADER | 52 HEADER |
52 | 53 |
53 | 54 |
54 if ($class->can('get_meta')) { | 55 if ($class->can('GetMeta')) { |
55 # meta supported | 56 # meta supported |
56 foreach my $prop_info (grep { | 57 foreach my $prop_info (grep { |
57 my $mutators = $_->mutators; | 58 $_->setter && ($_->access & ACCESS_PUBLIC); |
58 ref $mutators ? (exists $mutators->{set}) : ($mutators & prop_set || $_->implementor->isa('IMPL::Class::Property::Direct')); | 59 } $class->GetMeta('IMPL::Class::PropertyInfo')) { |
59 } $class->get_meta('IMPL::Class::PropertyInfo')) { | |
60 my $name = $prop_info->name; | 60 my $name = $prop_info->name; |
61 if (ref $prop_info->mutators || !$prop_info->implementor->isa('IMPL::Class::Property::Direct')) { | 61 if ($prop_info->isa('IMPL::Class::DirectPropertyInfo')) { |
62 $text .= " \$this->$name(\$fields->{$name}) if exists \$fields->{$name};\n"; | 62 $text .= " \$this->$name(\$fields->{$name}) if exists \$fields->{$name};\n"; |
63 } else { | 63 } else { |
64 my $fld = $prop_info->implementor->FieldName($prop_info); | 64 my $fld = $prop_info->fieldName; |
65 if ($prop_info->mutators & prop_list) { | 65 if ($prop_info->isList) { |
66 $text .= " \$this->{$fld} = IMPL::Object::List->new ( ref \$fields->{$name} ? \$fields->{$name} : [\$fields->{$name}] ) if exists \$fields->{$name};\n"; | 66 $text .= " \$this->{$fld} = IMPL::Object::List->new ( ref \$fields->{$name} ? \$fields->{$name} : [\$fields->{$name}] ) if exists \$fields->{$name};\n"; |
67 } else { | 67 } else { |
68 $text .= " \$this->{$fld} = \$fields->{$name} if exists \$fields->{$name};\n"; | 68 $text .= " \$this->{$fld} = \$fields->{$name} if exists \$fields->{$name};\n"; |
69 } | 69 } |
70 } | 70 } |