From: Stevan Little Date: Thu, 17 Aug 2006 14:57:39 +0000 (+0000) Subject: more misc cleanup X-Git-Tag: 0_33~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1396f86b13c09fb467ee1cf1e30168d5b138b7b1;p=gitmo%2FClass-MOP.git more misc cleanup --- diff --git a/Changes b/Changes index 2789204..c7fd2c5 100644 --- a/Changes +++ b/Changes @@ -10,6 +10,8 @@ Revision history for Perl extension Class-MOP. are no longer allowed for defaults - added tests for this + ~ lots of misc. documentation cleanup + 0.32 Sat. Aug. 12, 2006 + added Class::MOP::Object so that the metamodel is more complete (and closer diff --git a/TODO b/TODO index 2fe9fb0..b7e04ab 100644 --- a/TODO +++ b/TODO @@ -1,19 +1,6 @@ --------------------------------------------------------------------- TODO ---------------------------------------------------------------------- - -- check out what chromatic said: - -I think you can check the class key <_ISA to see if it has expired. - -- switch to Context::Handle for method modifiers - -Should probably write some more tests to verify this works correctly -when we add it in, to make sure we don't break weird stuff. - -- add ::Attribute::Collection types - -mugwump was working on this ... +--------------------------------------------------------------------- - do not bless methods unless asked diff --git a/lib/Class/MOP/Attribute.pm b/lib/Class/MOP/Attribute.pm index 4e3eb09..6fafa5d 100644 --- a/lib/Class/MOP/Attribute.pm +++ b/lib/Class/MOP/Attribute.pm @@ -7,7 +7,7 @@ use warnings; use Carp 'confess'; use Scalar::Util 'blessed', 'reftype', 'weaken'; -our $VERSION = '0.12'; +our $VERSION = '0.13'; our $AUTHORITY = 'cpan:STEVAN'; sub meta { @@ -108,7 +108,7 @@ sub init_arg { $_[0]->{init_arg} } # (all methods below here are kept intact) sub is_default_a_coderef { - (reftype($_[0]->{default}) && reftype($_[0]->{default}) eq 'CODE') + ('CODE' eq (reftype($_[0]->{default}) || '')) } sub default { @@ -144,7 +144,7 @@ sub detach_from_class { ## Slot management sub set_value { - my ( $self, $instance, $value ) = @_; + my ($self, $instance, $value) = @_; Class::MOP::Class->initialize(Scalar::Util::blessed($instance)) ->get_meta_instance @@ -152,11 +152,11 @@ sub set_value { } sub get_value { - my ( $self, $instance ) = @_; + my ($self, $instance) = @_; Class::MOP::Class->initialize(Scalar::Util::blessed($instance)) ->get_meta_instance - ->get_slot_value( $instance, $self->name ); + ->get_slot_value($instance, $self->name); } ## Method generation helpers @@ -164,8 +164,8 @@ sub get_value { sub generate_accessor_method { my $attr = shift; return sub { - $attr->set_value( $_[0], $_[1] ) if scalar(@_) == 2; - $attr->get_value( $_[0] ); + $attr->set_value($_[0], $_[1]) if scalar(@_) == 2; + $attr->get_value($_[0]); }; } @@ -187,7 +187,7 @@ sub generate_reader_method { my $attr = shift; return sub { confess "Cannot assign a value to a read-only accessor" if @_ > 1; - $attr->get_value( $_[0] ); + $attr->get_value($_[0]); }; } @@ -208,7 +208,7 @@ sub generate_reader_method_inline { sub generate_writer_method { my $attr = shift; return sub { - $attr->set_value( $_[0], $_[1] ); + $attr->set_value($_[0], $_[1]); }; } diff --git a/lib/Class/MOP/Class/Immutable.pm b/lib/Class/MOP/Class/Immutable.pm index 2baab34..574257d 100644 --- a/lib/Class/MOP/Class/Immutable.pm +++ b/lib/Class/MOP/Class/Immutable.pm @@ -14,12 +14,12 @@ use base 'Class::MOP::Class'; # methods which can *not* be called -sub add_method { confess 'Cannot call method "add_method" on an immutable instance' } -sub alias_method { confess 'Cannot call method "alias_method" on an immutable instance' } -sub remove_method { confess 'Cannot call method "remove_method" on an immutable instance' } - -sub add_attribute { confess 'Cannot call method "add_attribute" on an immutable instance' } -sub remove_attribute { confess 'Cannot call method "remove_attribute" on an immutable instance' } +sub add_method { confess 'Cannot call method "add_method" on an immutable instance' } +sub alias_method { confess 'Cannot call method "alias_method" on an immutable instance' } +sub remove_method { confess 'Cannot call method "remove_method" on an immutable instance' } + +sub add_attribute { confess 'Cannot call method "add_attribute" on an immutable instance' } +sub remove_attribute { confess 'Cannot call method "remove_attribute" on an immutable instance' } sub add_package_symbol { confess 'Cannot call method "add_package_symbol" on an immutable instance' } sub remove_package_symbol { confess 'Cannot call method "remove_package_symbol" on an immutable instance' }