- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- :i/プロトタイピング/Snippet/AutoloadAccessor へ行く。
- 1 (2009-11-29 (日) 00:42:51)
- 2 (2013-03-20 (水) 22:31:00)
package AutoloadAccessor;
use base qw{Exporter};
our @EXPORT = qw{_Recompose _Do};
sub _Recompose
{
my $self = shift;
my($autoload, @value) = @_;
my($method, $field) = $autoload =~ m/(=?Fetch|Store|Execute)_(\w+)/;
if (defined $method and defined $field and $self->can("${method}_${field}")){
return $self->_Do($method, $field, @value);
}
else {
die "Undefind method \"$autoload\".\n";
}
}
sub _Do
{
my $self = shift;
my($method, $field, @value) = @_;
if ($method eq 'Fetch'){
$self->{$field};
}
elsif ($method eq 'Store'){
$self->{$field} = $value[0];
}
elsif ($method eq 'Execute'){
do $self->{$field};
}
else {
die "Undefind method \"${method}_${field}\".\n";
}
# 戻値が変わってしまうので、これ以上コードを書けない。
}
1;
=DESCRIPTION
use subs qw{
Store_Id Fetch_Id Store_Ethernal Fetch_Ethernal Store_Owner Fetch_Owner
};
use AutoloadAccessor;
sub AUTOLOAD
{
return if our $AUTOLOAD =~ /::DESTROY$/; die unless not $AUTOLOAD =~ /::_Recompose$/; _Recompose($_[0], $AUTOLOAD, @_[1 .. $#_]);
}
=cut
