Mercurial > pub > Impl
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/IMPL/DOM/Schema/Label.pm Fri Sep 04 19:40:23 2015 +0300 @@ -0,0 +1,59 @@ +package IMPL::DOM::Schema::Label; +use strict; +use overload + '""' => 'ToString', + 'bool' => sub { return 1; }, + 'fallback' => 1; + +use IMPL::Const qw(:prop); +use IMPL::Exception(); +use IMPL::declare { + require => { + ArgException => '-IMPL::InvalidArgumentException' + }, + base => [ + 'IMPL::Object' => undef + ], + props => [ + _map => PROP_RW, + _id => PROP_RW + ] +}; + +sub CTOR { + my ($this,$map,$id) = @_; + + die ArgException->new('map' => 'A strings map is required') + unless $map; + die ArgException->new('id' => 'A lable identifier is required') + unless $id; + + $this->_map($map); + $this->_id($id); +} + +our $AUTOLOAD; +sub AUTOLOAD { + my ($this) = @_; + + my ($method) = ($AUTOLOAD =~ /(\w+)$/); + return + if $method eq 'DESTROY'; + + warn $this->_id . ".$method"; + + return $this->new($this->_map,$this->_id . ".$method"); +} + +sub ToString { + my ($this) = @_; + return $this->_map->GetString($this->_id); +} + +sub Format { + my ($this,$args) = @_; + + return $this->_map->GetString($this->_id,$args); +} + +1; \ No newline at end of file