Created
October 21, 2011 15:54
-
-
Save stevan/1304188 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
::Class.meta.add_method('CREATE' => method (%params) { | |
# this just gathers all the | |
# attributes that were defined | |
# for the instances. | |
my %attrs; | |
my Dispatcher $dispatcher = $class.dispatcher(:descendant); | |
for WALKCLASS($dispatcher) -> Class $c { | |
for $c.get_attribute_list() -> $attr { | |
my $attr_obj = $c.get_attribute($attr); | |
%attrs{$attr} = instantiate_attribute_container($attr_obj); | |
} | |
} | |
# this is our P6opaque data structure | |
# it's nothing special, but it works :) | |
my OpaqueInstance $self = create_opaque_instance(\$class, %attrs); | |
# and now return it ... | |
return $self; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment