my ( $self, $context ) = @_;
$context ||= $self->definition_context;
- return "generated method (unknown origin)"
- unless defined $context;
-
- if (defined $context->{description}) {
- return "$context->{description} "
- . "(defined at $context->{file} line $context->{line})";
- } else {
- return "$context->{file} (line $context->{line})";
+ my $desc = "generated method";
+ my $origin = "unknown origin";
+
+ if (defined $context) {
+ if (defined $context->{description}) {
+ $desc = $context->{description};
+ }
+
+ if (defined $context->{file} || defined $context->{line}) {
+ $origin = "defined at "
+ . (defined $context->{file}
+ ? $context->{file} : "<unknown file>")
+ . " line "
+ . (defined $context->{line}
+ ? $context->{line} : "<unknown line>");
+ }
}
+
+ return "$desc ($origin)";
}
sub _compile_code {
unless $options{curried_arguments}
&& ref($options{curried_arguments}) eq 'ARRAY';
- $options{definition_context} = $options{attribute}->definition_context;
+ my $attr_context = $options{attribute}->definition_context;
+ my $desc = 'native delegation method ';
+ $desc .= $options{attribute}->associated_class->name;
+ $desc .= '::' . $options{name};
+ $desc .= " ($options{delegate_to_method})";
+ $desc .= " of attribute " . $options{attribute}->name;
+ $options{definition_context} = {
+ %{ $attr_context || {} },
+ description => $desc,
+ };
$options{accessor_type} = 'native';