Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@colomon
Created March 13, 2014 20:09
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 colomon/b598829a9419bdb5a2ed to your computer and use it in GitHub Desktop.
Save colomon/b598829a9419bdb5a2ed to your computer and use it in GitHub Desktop.
role HwDumpObject {
has $.id;
has %.attributes;
method initialize-attributes(@raw-attributes) {
for @raw-attributes -> $attribute {
warn "Strange number of keys in attribute" if $attribute.keys != 1;
my $key = $attribute.keys[0];
warn "Attribute $key found more than once" if %.attributes{$key};
%.attributes{$key} = $attribute{$key};
}
$.id = %.attribute<ID> // "no id";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment