Mercurial > pub > Impl
comparison Lib/IMPL/Class/Template.pm @ 194:4d0e1962161c
Replaced tabs with spaces
IMPL::Web::View - fixed document model, new features (control classes, document constructor parameters)
| author | cin |
|---|---|
| date | Tue, 10 Apr 2012 20:08:29 +0400 |
| parents | d1676be8afcc |
| children |
comparison
equal
deleted
inserted
replaced
| 193:8e8401c0aea4 | 194:4d0e1962161c |
|---|---|
| 2 use strict; | 2 use strict; |
| 3 use IMPL::lang; | 3 use IMPL::lang; |
| 4 use IMPL::_core::version; | 4 use IMPL::_core::version; |
| 5 | 5 |
| 6 sub makeName { | 6 sub makeName { |
| 7 my ($class,@params) = @_; | 7 my ($class,@params) = @_; |
| 8 | 8 |
| 9 $_ =~ s/^.*::(\w+)$/$1/ foreach @params; | 9 $_ =~ s/^.*::(\w+)$/$1/ foreach @params; |
| 10 return join('',$class,@params); | 10 return join('',$class,@params); |
| 11 } | 11 } |
| 12 | 12 |
| 13 1; | 13 1; |
| 14 | 14 |
| 15 __END__ | 15 __END__ |
| 27 package KeyValuePair; | 27 package KeyValuePair; |
| 28 | 28 |
| 29 use IMPL::Class::Property; | 29 use IMPL::Class::Property; |
| 30 | 30 |
| 31 use IMPL::template ( | 31 use IMPL::template ( |
| 32 parameters => [qw(TKey TValue))], | 32 parameters => [qw(TKey TValue))], |
| 33 base => [qw(IMPL::Object IMPL::Object::Autofill)], | 33 base => [qw(IMPL::Object IMPL::Object::Autofill)], |
| 34 declare => sub { | 34 declare => sub { |
| 35 my ($class) = @_; | 35 my ($class) = @_; |
| 36 public $class->CreateProperty(key => prop_get | owner_set, { type => $class->TKey } ); | 36 public $class->CreateProperty(key => prop_get | owner_set, { type => $class->TKey } ); |
| 37 public $class->CreateProperty(value => prop_all, { type => $class->TValue} ); | 37 public $class->CreateProperty(value => prop_all, { type => $class->TValue} ); |
| 38 | 38 |
| 39 $class->PassThroughArgs; | 39 $class->PassThroughArgs; |
| 40 } | 40 } |
| 41 ); | 41 ); |
| 42 | 42 |
| 43 BEGIN { | 43 BEGIN { |
| 44 public property id => prop_get | owner_set, { type => 'integer'}; | 44 public property id => prop_get | owner_set, { type => 'integer'}; |
| 45 } | 45 } |
| 46 | 46 |
| 47 __PACKAGE__->PassThroughArgs; | 47 __PACKAGE__->PassThroughArgs; |
| 48 | 48 |
| 49 package MyCollection; | 49 package MyCollection; |
| 50 | 50 |
| 51 use IMPL::Class::Property; | 51 use IMPL::Class::Property; |
| 52 | 52 |
| 53 use IMPL::lang; | 53 use IMPL::lang; |
| 54 use IMPL::template( | 54 use IMPL::template( |
| 55 parameters => [qw(TKey TValue)], | 55 parameters => [qw(TKey TValue)], |
| 56 base => [qw(IMPL::Object)], | 56 base => [qw(IMPL::Object)], |
| 57 declare => sub { | 57 declare => sub { |
| 58 my ($class) = @_; | 58 my ($class) = @_; |
| 59 my $item_t = spec KeyValuePair($class->TKey,$class->TValue); | 59 my $item_t = spec KeyValuePair($class->TKey,$class->TValue); |
| 60 | 60 |
| 61 public $class->CreateProperty(items => prop_get | prop_list, { type => $item_t } ) | 61 public $class->CreateProperty(items => prop_get | prop_list, { type => $item_t } ) |
| 62 | 62 |
| 63 $class->static_accessor( ItemType => $item_t ); | 63 $class->static_accessor( ItemType => $item_t ); |
| 64 } | 64 } |
| 65 ) | 65 ) |
| 66 | 66 |
| 67 sub Add { | 67 sub Add { |
| 68 my ($this,$key,$value) = @_; | 68 my ($this,$key,$value) = @_; |
| 69 | 69 |
| 70 die new IMPL::ArgumentException( key => "Invalid argument type" ) unless is $key, $this->TKey; | 70 die new IMPL::ArgumentException( key => "Invalid argument type" ) unless is $key, $this->TKey; |
| 71 die new IMPL::ArgumentException( value => "Invalid argument type" ) unless is $value, $this->TValue; | 71 die new IMPL::ArgumentException( value => "Invalid argument type" ) unless is $value, $this->TValue; |
| 72 | 72 |
| 73 $this->items->AddLast( $this->ItemType->new( key => $key, value => $value ) ); | 73 $this->items->AddLast( $this->ItemType->new( key => $key, value => $value ) ); |
| 74 } | 74 } |
| 75 | 75 |
| 76 =end code | 76 =end code |
| 77 | 77 |
| 78 =head1 DESCRIPTION | 78 =head1 DESCRIPTION |
