comparison lib/IMPL/DOM/Schema/Label.pm @ 407:c6e90e02dd17 ref20150831

renamed Lib->lib
author cin
date Fri, 04 Sep 2015 19:40:23 +0300
parents
children
comparison
equal deleted inserted replaced
406:f23fcb19d3c1 407:c6e90e02dd17
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 $this->_map($map);
32 $this->_id($id);
33 }
34
35 our $AUTOLOAD;
36 sub AUTOLOAD {
37 my ($this) = @_;
38
39 my ($method) = ($AUTOLOAD =~ /(\w+)$/);
40 return
41 if $method eq 'DESTROY';
42
43 warn $this->_id . ".$method";
44
45 return $this->new($this->_map,$this->_id . ".$method");
46 }
47
48 sub ToString {
49 my ($this) = @_;
50 return $this->_map->GetString($this->_id);
51 }
52
53 sub Format {
54 my ($this,$args) = @_;
55
56 return $this->_map->GetString($this->_id,$args);
57 }
58
59 1;