-
-
Save anonymous/029a0d26422198e7947e 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.^attributes -> $attr { | |
if %pars{$attr.name.substr(2)}:exists { | |
if $attr.type ~~ ResourceRelation { | |
%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