use Sub::Name 'subname';
use B 'svref_2object';
-our $VERSION = '0.01';
+our $VERSION = '0.02';
# Self-introspection
## Methods
+# un-used right now ...
+sub method_metaclass { 'Class::MOP::Method' }
+
sub add_method {
my ($self, $method_name, $method) = @_;
(defined $method_name && $method_name)
## Attributes
+sub attribute_metaclass { 'Class::MOP::Attribute' }
+
sub add_attribute {
- my ($self,$attribute) = @_;
- (blessed($attribute) && $attribute->isa('Class::MOP::Attribute'))
- || confess "Your attribute must be an instance of Class::MOP::Attribute (or a subclass)";
+ my $self = shift;
+ # either we have an attribute object already
+ # or we need to create one from the args provided
+ my $attribute = blessed($_[0]) ? $_[0] : $self->attribute_metaclass->new(@_);
+ # make sure it is derived from the correct type though
+ ($attribute->isa('Class::MOP::Attribute'))
+ || confess "Your attribute must be an instance of Class::MOP::Attribute (or a subclass)";
$attribute->attach_to_class($self);
$attribute->install_accessors();
$self->{'%:attrs'}->{$attribute->name} = $attribute;
=over 4
+=item B<method_metaclass>
+
=item B<add_method ($method_name, $method)>
This will take a C<$method_name> and CODE reference to that
=over 4
+=item B<attribute_metaclass>
+
=item B<add_attribute ($attribute_name, $attribute_meta_object)>
This stores a C<$attribute_meta_object> in the B<Class::MOP::Class>