Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Mu.gist: call .gist on attributes, not .perl
Closes RT #123016
  • Loading branch information
moritz committed Oct 21, 2014
1 parent 4699b5a commit 10eb3fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/core/Enum.pm
Expand Up @@ -35,6 +35,9 @@ my class Enum does Associative {
$.key.perl ~ ' => ' ~ $.value.perl;
}
}
multi method gist(Enum:D:) {
self.key.gist ~ ' => ' ~ self.value.gist
}

method fmt($format = "%s\t%s") {
sprintf($format, $.key, $.value);
Expand Down
11 changes: 10 additions & 1 deletion src/core/Mu.pm
Expand Up @@ -440,7 +440,16 @@ my class Mu { # declared in BOOTSTRAP

proto method gist(|) { * }
multi method gist(Mu:U:) { '(' ~ self.HOW.name(self) ~ ')' }
multi method gist(Mu:D:) { self.perl }
multi method gist(Mu:D:) {
my @attrs;
for self.^attributes().grep: { .has_accessor } -> $attr {
my $name := $attr.Str.substr(2);
@attrs.push: $name
~ ' => '
~ self."$name"().gist
}
self.HOW.name(self) ~ '(' ~ @attrs.join(', ') ~ ')';
}

proto method perl(|) { * }
multi method perl(Mu:U:) { self.HOW.name(self) }
Expand Down

0 comments on commit 10eb3fa

Please sign in to comment.