Mercurial > pub > Impl
comparison Lib/IMPL/DOM/Schema/Label.pm @ 381:ced5937ff21a
Custom getters/setters support method names in theirs definitions
Initial support for localizable labels in DOM schemas
author | cin |
---|---|
date | Wed, 22 Jan 2014 16:56:10 +0400 |
parents | |
children | 2f16f13b000c |
comparison
equal
deleted
inserted
replaced
380:1eca08048ba9 | 381:ced5937ff21a |
---|---|
1 package IMPL::DOM::Schema::Label; | |
2 use strict; | |
3 use overload | |
4 '""' => 'ToString', | |
5 'bool' => sub { return 1; }, | |
6 'fallback' => 1; | |
7 | |
8 use IMPL::Const qw(:prop); | |
9 use IMPL::Exception(); | |
10 use IMPL::declare { | |
11 require => { | |
12 ArgException => '-IMPL::InvalidArgumentException' | |
13 }, | |
14 base => [ | |
15 'IMPL::Object' => undef | |
16 ], | |
17 props => [ | |
18 _map => PROP_RW, | |
19 _id => PROP_RW | |
20 ] | |
21 }; | |
22 | |
23 sub CTOR { | |
24 my ($this,$map,$id) = @_; | |
25 | |
26 die ArgException->new('map' => 'A strings map is required') | |
27 unless $map; | |
28 die ArgException->new('id' => 'A lable identifier is required') | |
29 unless $id; | |
30 } | |
31 | |
32 our $AUTOLOAD; | |
33 sub AUTOLOAD { | |
34 my ($this) = @_; | |
35 | |
36 my ($method) = ($AUTOLOAD =~ /(\w+)$/); | |
37 return | |
38 if $method eq 'DESTROY'; | |
39 | |
40 return $this->new($this->_map,$method); | |
41 } | |
42 | |
43 sub ToString { | |
44 my ($this) = @_; | |
45 return $this->_map->GetString($this->_id); | |
46 } | |
47 | |
48 1; |