* Class::MOP::Class
- refactored all symbol table access to
use Class::MOP::Package methods instead
+
+ * Class::MOP::Module
+ - adding the $:version attribute in the bootstrap
+ so that Module has a version as an attribute
+ - see comment in Class::MOP for details
+ - added the $:authority attribute to this module
+ as well as an &identifier method, to bring us
+ ever closer to Perl 6 goodness
- * Class::MOP::Instance
- - added &deinitialize_slot for removing slots
- from an instance
- - added tests for this
+ * Class::MOP::Instance
+ - added &deinitialize_slot for removing slots
+ from an instance
+ - added tests for this
* Class::MOP::Attribute
- added support for &deinitialize_slot for removing
use Class::MOP::Class::Immutable;
-our $VERSION = '0.32';
+our $VERSION = '0.32';
+our $AUTHORITY = 'cpan:STEVAN';
## ----------------------------------------------------------------------------
## Setting up our environment ...
# any subclass of Class::MOP::* will be able to
# inherit them using &construct_instance
+## --------------------------------------------------------
## Class::MOP::Package
Class::MOP::Package->meta->add_attribute(
$class->meta->new_object(':package' => $package_name, @_);
});
+## --------------------------------------------------------
+## Class::MOP::Module
+
+# NOTE:
+# yeah this is kind of stretching things a bit,
+# but truthfully the version should be an attribute
+# of the Module, the weirdness comes from having to
+# stick to Perl 5 convention and store it in the
+# $VERSION package variable. Basically if you just
+# squint at it, it will look how you want it to look.
+# Either as a package variable, or as a attribute of
+# the metaclass, isn't abstraction great :)
+
+Class::MOP::Module->meta->add_attribute(
+ Class::MOP::Attribute->new('$:version' => (
+ reader => {
+ 'version' => sub {
+ my $self = shift;
+ ${$self->get_package_symbol('$VERSION')};
+ }
+ },
+ # NOTE:
+ # protect this from silliness
+ init_arg => '!............( DO NOT DO THIS )............!',
+ ))
+);
+
+# NOTE:
+# By following the same conventions as version here,
+# we are opening up the possibility that people can
+# use the $AUTHORITY in non-Class::MOP modules as
+# well.
+
+Class::MOP::Module->meta->add_attribute(
+ Class::MOP::Attribute->new('$:authority' => (
+ reader => {
+ 'authority' => sub {
+ my $self = shift;
+ ${$self->get_package_symbol('$AUTHORITY')};
+ }
+ },
+ # NOTE:
+ # protect this from silliness
+ init_arg => '!............( DO NOT DO THIS )............!',
+ ))
+);
+
+## --------------------------------------------------------
## Class::MOP::Class
Class::MOP::Class->meta->add_attribute(
# within Class::MOP::Class itself in the
# construct_class_instance method.
+## --------------------------------------------------------
## Class::MOP::Attribute
Class::MOP::Attribute->meta->add_attribute(
$self->meta->clone_object($self, @_);
});
-## Try and close Class::MOP::*
+## --------------------------------------------------------
+## Now close all the Class::MOP::* classes
Class::MOP::Package ->meta->make_immutable(inline_constructor => 0);
Class::MOP::Module ->meta->make_immutable(inline_constructor => 0);
Class::MOP::Method ->meta->make_immutable(inline_constructor => 0);
Class::MOP::Instance ->meta->make_immutable(inline_constructor => 0);
-
1;
__END__
use Carp 'confess';
use Scalar::Util 'blessed', 'reftype', 'weaken';
-our $VERSION = '0.11';
+our $VERSION = '0.11';
+our $AUTHORITY = 'cpan:STEVAN';
sub meta {
require Class::MOP::Class;
use Sub::Name 'subname';
use B 'svref_2object';
-our $VERSION = '0.17';
+our $VERSION = '0.17';
+our $AUTHORITY = 'cpan:STEVAN';
use base 'Class::MOP::Module';
if ($class =~ /^Class::MOP::Class$/) {
no strict 'refs';
$meta = bless {
+ # inherited from Class::MOP::Package
'$:package' => $package_name,
'%:namespace' => \%{$package_name . '::'},
+ # inherited from Class::MOP::Module
+ '$:version' => (exists ${$package_name . '::'}{'VERSION'} ? ${$package_name . '::VERSION'} : undef),
+ '$:authority' => (exists ${$package_name . '::'}{'AUTHORITY'} ? ${$package_name . '::AUTHORITY'} : undef),
+ # defined here ...
'%:attributes' => {},
'$:attribute_metaclass' => $options{':attribute_metaclass'} || 'Class::MOP::Attribute',
'$:method_metaclass' => $options{':method_metaclass'} || 'Class::MOP::Method',
use Carp 'confess';
use Scalar::Util 'blessed', 'looks_like_number';
-our $VERSION = '0.02';
+our $VERSION = '0.02';
+our $AUTHORITY = 'cpan:STEVAN';
use base 'Class::MOP::Class';
use Scalar::Util 'weaken', 'blessed';
-our $VERSION = '0.03';
+our $VERSION = '0.03';
+our $AUTHORITY = 'cpan:STEVAN';
sub meta {
require Class::MOP::Class;
use Scalar::Util 'reftype', 'blessed';
use B 'svref_2object';
-our $VERSION = '0.03';
+our $VERSION = '0.03';
+our $AUTHORITY = 'cpan:STEVAN';
# introspection
use Scalar::Util 'blessed';
our $VERSION = '0.02';
-#our $AUTHORITY = {
-# cpan => 'STEVAN',
-# mailto => 'stevan@iinteractive.com',
-# http => '//www.iinteractive.com/'
-#};
+our $AUTHORITY = 'cpan:STEVAN';
use base 'Class::MOP::Package';
Class::MOP::Class->initialize(blessed($_[0]) || $_[0]);
}
-# QUESTION:
-# can the version be an attribute of the
-# module? I think it should be, but we need
-# to somehow assure that it always is stored
-# in the symbol table instead of being stored
-# into the instance structure itself
-
sub version {
my $self = shift;
${$self->get_package_symbol('$VERSION')};
}
-#sub authority {
-# my $self = shift;
-# $self->get_package_symbol('$AUTHORITY');
-#}
+sub authority {
+ my $self = shift;
+ ${$self->get_package_symbol('$AUTHORITY')};
+}
+sub identifier {
+ my $self = shift;
+ join '-' => (
+ $self->name,
+ ($self->version || ()),
+ ($self->authority || ()),
+ );
+}
1;
=item B<version>
+=item B<authority>
+
+=item B<identifier>
+
=back
=head1 AUTHORS
use Scalar::Util 'blessed';
use Carp 'confess';
-our $VERSION = '0.02';
+our $VERSION = '0.02';
+our $AUTHORITY = 'cpan:STEVAN';
# introspection
use Carp 'confess';
use Scalar::Util 'blessed';
-our $VERSION = '0.03';
+our $VERSION = '0.03';
+our $AUTHORITY = 'cpan:STEVAN';
use Class::MOP;
use strict;
use warnings;
-use Test::More tests => 181;
+use Test::More tests => 189;
use Test::Exception;
BEGIN {
my @class_mop_module_methods = qw(
meta
- version
+ version authority identifier
);
my @class_mop_class_methods = qw(
);
my @class_mop_module_attributes = (
+ '$:version', '$:authority'
);
my @class_mop_class_attributes = (