Permalink
Browse files

cleanup

  • Loading branch information...
1 parent efb2f16 commit 3b30bb2a23d5b0ac4bd9ccc399267c79141f087b @yuki-kimoto yuki-kimoto committed Dec 15, 2009
Showing with 16 additions and 10 deletions.
  1. +5 −4 lib/Object/Simple.pm
  2. +11 −6 lib/Object/Simple/Util.pm
View
@@ -245,11 +245,12 @@ sub build_class {
. $U->create_translate_accessor($class, $accessor_name);
}
elsif ($accessor_type eq 'Output') {
- ### Output accessor will be deleted in future ###
+ # (Output accessor will be deleted in future)
# Create output accessor
- $accessor_code
- .= "package $class;\nsub $accessor_name "
- . $U->create_output_accessor($class, $accessor_name);
+
+ no strict 'refs';
+ no warnings qw(redefine);
+ *{"${class}::$accessor_name"} = $U->create_output_accessor($class, $accessor_name);
}
elsif ($accessor_type eq 'ClassObjectAttr') {
# Create class and object hibrid accessor
View
@@ -573,12 +573,17 @@ sub create_output_accessor {
my ($self, $class, $accessor_name) = @_;
my $target = $self->class_infos->{$class}{accessors}{$accessor_name}{options}{target};
- my $code = qq/{\n/ .
- qq/ my (\$self, \$output) = \@_;\n/ .
- qq/ my \$value = \$self->$target;\n/ .
- qq/ \$\$output = \$value;\n/ .
- qq/ return \$self\n/ .
- qq/}\n\n/;
+ my $source = qq/sub {\n/ .
+ qq/ package $class;\n/ .
+ qq/ my (\$self, \$output) = \@_;\n/ .
+ qq/ my \$value = \$self->$target;\n/ .
+ qq/ \$\$output = \$value;\n/ .
+ qq/ return \$self\n/ .
+ qq/}\n\n/;
+
+ my $code = eval $source;
+
+ croak("$source\n:$@") if $@;
return $code;
}

0 comments on commit 3b30bb2

Please sign in to comment.