Created
November 1, 2015 22:48
-
-
Save lizmat/d01f35e64b648578e3a4 to your computer and use it in GitHub Desktop.
Adding .^attribute for hash based introspection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Perl6/Metamodel/AttributeContainer.nqp b/src/Perl6/Metamodel/AttributeContainer.nqp | |
index a5fafdd..bc0a525 100644 | |
--- a/src/Perl6/Metamodel/AttributeContainer.nqp | |
+++ b/src/Perl6/Metamodel/AttributeContainer.nqp | |
@@ -76,4 +76,22 @@ role Perl6::Metamodel::AttributeContainer { | |
@attrs | |
} | |
+ | |
+ method attribute($obj, :$local, :$excl, :$all) { | |
+ my %attrs; | |
+ | |
+ for @!attributes { | |
+ %attrs{$_.name} := $_; | |
+ } | |
+ | |
+ unless $local { | |
+ for self.parents($obj, :excl($excl), :all($all)) { | |
+ for $_.HOW.attributes($_, :local(1)) { | |
+ %attrs{$_.name} := $_; | |
+ } | |
+ } | |
+ } | |
+ | |
+ %attrs | |
+ } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment