-
-
Save anonymous/fc9b1965a61f5aa51725 to your computer and use it in GitHub Desktop.
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
MacBookProRetinaFCO:JSON_API fernando$ cat ResourceRelation.pm6 | |
role ResourceRelation[$type] { | |
method type {$type}; | |
} | |
MacBookProRetinaFCO:JSON_API fernando$ perl6 -I. -e 'use ResourceRelation; | |
class Bla { | |
has ResourceRelation["ble"] $.teste; | |
submethod BUILD(*%pars) { | |
for self.^attribute -> $attr { | |
if %pars{$attr.name.substr(2)}:exists { | |
if $attr.type ~~ role { | |
%pars{$attr.name.substr(2)} does $attr.type; | |
} | |
$attr.set_value(self, %pars{$attr.name.substr(2)}) | |
} | |
} | |
} | |
$a = Bla.new(:teste(42)); | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment