Skip to content

Instantly share code, notes, and snippets.

Created February 22, 2015 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/fc9b1965a61f5aa51725 to your computer and use it in GitHub Desktop.
Save anonymous/fc9b1965a61f5aa51725 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.^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