Skip to content

Instantly share code, notes, and snippets.

Created February 22, 2015 23:51
Show Gist options
  • Save anonymous/029a0d26422198e7947e to your computer and use it in GitHub Desktop.
Save anonymous/029a0d26422198e7947e to your computer and use it in GitHub Desktop.
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