Revision history for Perl extension Class-MOP.
-NEXT
+0.56
* Class::MOP::Attribute
- add has_read_method and has_write_method
+
+ * Class::MOP::Immutable
+ - added the ability to "wrap" methods when
+ making the class immutable
+
+ * Class::MOP::Class
+ - now handling the edge case of ->meta->indentifier
+ dying by wrapping add_package_symbol to specifically
+ allow for it to work.
+ - added tests for this
0.55 Mon. April 28, 2008
- All classes now have proper C3 MRO support
use Scalar::Util 'blessed', 'reftype', 'weaken';
use Sub::Name 'subname';
-our $VERSION = '0.30';
+our $VERSION = '0.31';
our $AUTHORITY = 'cpan:STEVAN';
use base 'Class::MOP::Module';
sub create_immutable_transformer {
my $self = shift;
my $class = Class::MOP::Immutable->new($self, {
- read_only => [qw/superclasses/],
- cannot_call => [qw/
+ read_only => [qw/superclasses/],
+ cannot_call => [qw/
add_method
alias_method
remove_method
add_attribute
remove_attribute
remove_package_symbol
- /],
- memoize => {
+ /],
+ memoize => {
class_precedence_list => 'ARRAY',
linearized_isa => 'ARRAY',
compute_all_applicable_attributes => 'ARRAY',
get_meta_instance => 'SCALAR',
get_method_map => 'SCALAR',
- },
- around => {
- add_package_symbol => sub {
- my $original = shift;
- confess "NO ADD SYMBOLS FOR YOU" unless caller eq 'get_package_symbol';
- $original->(@_);
- },
- },
+ },
+ # NOTE:
+ # this is ugly, but so are typeglobs,
+ # so whattayahgonnadoboutit
+ # - SL
+ wrapped => {
+ add_package_symbol => sub {
+ my $original = shift;
+ confess "Cannot add package symbols to an immutable metaclass"
+ unless (caller(2))[3] eq 'Class::MOP::Package::get_package_symbol';
+ goto $original->body;
+ },
+ },
});
return $class;
}
use Scalar::Util 'blessed';
use Sub::Name 'subname';
-our $VERSION = '0.05';
+our $VERSION = '0.06';
our $AUTHORITY = 'cpan:STEVAN';
use base 'Class::MOP::Object';
}
}
- my $around_methods = $self->options->{around};
- foreach my $method_name (keys %{$around_methods}) {
+ my $wrapped_methods = $self->options->{wrapped};
+
+ foreach my $method_name (keys %{ $wrapped_methods }) {
my $method = $self->metaclass->meta->find_method_by_name($method_name);
- $method = Class::MOP::Method::Wrapped->wrap($method);
- $method->add_around_modifier(subname ':around' => $around_methods->{$method_name});
+
+ (defined $method)
+ || confess "Could not find the method '$method_name' in " . $self->metaclass->name;
+
+ my $wrapper = $wrapped_methods->{$method_name};
+
+ $methods{$method_name} = sub { $wrapper->($method, @_) };
}
$methods{get_mutable_metaclass_name} = sub { (shift)->{'___original_class'} };
dies_ok { $meta->add_package_symbol() } '... exception thrown as expected';
dies_ok { $meta->remove_package_symbol() } '... exception thrown as expected';
- lives_ok{ $meta->identifier() } '... no exception for get_package_symbol special case';
+
+ lives_ok { $meta->identifier() } '... no exception for get_package_symbol special case';
my @supers;
lives_ok {