my $class = shift;
return Class::MOP::Class->initialize($class)->new_object(@_)
- if $class ne __PACKAGE__;
+ if $class ne __PACKAGE__;
my $options = @_ == 1 ? $_[0] : {@_};
use Class::MOP::Method::Constructor;
use Carp 'confess';
-use Scalar::Util 'blessed', 'weaken';
+use Scalar::Util 'blessed', 'reftype', 'weaken';
use Sub::Name 'subname';
use Devel::GlobalDestruction 'in_global_destruction';
sub _new {
my $class = shift;
+
return Class::MOP::Class->initialize($class)->new_object(@_)
- if $class ne __PACKAGE__;
+ if $class ne __PACKAGE__;
my $options = @_ == 1 ? $_[0] : {@_};
# NOTE:
# this will only work for a HASH instance type
if ($class->is_anon_class) {
- (Scalar::Util::reftype($instance) eq 'HASH')
+ (reftype($instance) eq 'HASH')
|| confess "Currently only HASH based instances are supported with instance of anon-classes";
# NOTE:
# At some point we should make this official
shift->add_method(@_);
}
-sub _code_is_mine{
- my($self, $code) = @_;
- my($code_package, $code_name) = Class::MOP::get_code_info($code);
- return $code_package
- && $code_package eq $self->name
- || ($code_package eq 'constant' && $code_name eq '__ANON__');
+sub _code_is_mine {
+ my ( $self, $code ) = @_;
+
+ my ( $code_package, $code_name ) = Class::MOP::get_code_info($code);
+
+ return $code_package && $code_package eq $self->name
+ || ( $code_package eq 'constant' && $code_name eq '__ANON__' );
}
sub has_method {
type => 'CODE',
});
- if (!($method_object && $method_object->body == ($code || 0))){
- if ($code && $self->_code_is_mine($code)) {
- $method_object = $method_map->{$method_name} = $self->wrap_method_body(
- body => $code,
- name => $method_name,
- associated_metaclass => $self,
- );
+ unless ( $method_object && $method_object->body == ( $code || 0 ) ) {
+ if ( $code && $self->_code_is_mine($code) ) {
+ $method_object = $method_map->{$method_name}
+ = $self->wrap_method_body(
+ body => $code,
+ name => $method_name,
+ associated_metaclass => $self,
+ );
}
else {
delete $method_map->{$method_name};
sub _new {
my $class = shift;
+
return Class::MOP::Class->initialize($class)->new_object(@_)
- if $class ne __PACKAGE__;
+ if $class ne __PACKAGE__;
my $params = @_ == 1 ? $_[0] : {@_};
my $class = shift;
return Class::MOP::Class->initialize($class)->new_object(@_)
- if $class ne __PACKAGE__;
+ if $class ne __PACKAGE__;
my $params = @_ == 1 ? $_[0] : {@_};
sub _new {
my $class = shift;
+
return Class::MOP::Class->initialize($class)->new_object(@_)
- if $class ne __PACKAGE__;
+ if $class ne __PACKAGE__;
my $params = @_ == 1 ? $_[0] : {@_};
use base 'Class::MOP::Package';
-sub _new{
+sub _new {
my $class = shift;
return Class::MOP::Class->initialize($class)->new_object(@_)
- if $class ne __PACKAGE__;
+ if $class ne __PACKAGE__;
my $params = @_ == 1 ? $_[0] : {@_};
return bless {
+
# from Class::MOP::Package
package => $params->{package},
namespace => \undef,
use strict;
use warnings;
-use Scalar::Util 'blessed';
+use Scalar::Util 'blessed', 'reftype';
use Carp 'confess';
our $VERSION = '0.89';
sub _new {
my $class = shift;
+
return Class::MOP::Class->initialize($class)->new_object(@_)
- if $class ne __PACKAGE__;
+ if $class ne __PACKAGE__;
my $params = @_ == 1 ? $_[0] : {@_};
# ... these functions deal with stuff on the namespace level
sub has_package_symbol {
- my ($self, $variable) = @_;
+ my ( $self, $variable ) = @_;
- my ($name, $sigil, $type) = ref $variable eq 'HASH'
+ my ( $name, $sigil, $type )
+ = ref $variable eq 'HASH'
? @{$variable}{qw[name sigil type]}
: $self->_deconstruct_variable_name($variable);
-
+
my $namespace = $self->namespace;
-
- return 0 unless exists $namespace->{$name};
-
+
+ return 0 unless exists $namespace->{$name};
+
my $entry_ref = \$namespace->{$name};
- if (ref($entry_ref) eq 'GLOB') {
- if ($type eq 'SCALAR') {
- return defined(${ *{$entry_ref}{SCALAR} });
+ if ( reftype($entry_ref) eq 'GLOB' ) {
+ if ( $type eq 'SCALAR' ) {
+ return defined( ${ *{$entry_ref}{SCALAR} } );
}
else {
- return defined(*{$entry_ref}{$type});
+ return defined( *{$entry_ref}{$type} );
}
- }
- else {
- # a symbol table entry can be -1 (stub), string (stub with prototype),
- # or reference (constant)
- return $type eq 'CODE';
+ }
+ else {
+
+ # a symbol table entry can be -1 (stub), string (stub with prototype),
+ # or reference (constant)
+ return $type eq 'CODE';
}
}
my $entry_ref = \$namespace->{$name};
- if (ref($entry_ref) eq 'GLOB') {
+ if ( ref($entry_ref) eq 'GLOB' ) {
return *{$entry_ref}{$type};
}
- else{
- if($type eq 'CODE'){
+ else {
+ if ( $type eq 'CODE' ) {
no strict 'refs';
- return \&{$self->name . '::' . $name};
+ return \&{ $self->name . '::' . $name };
}
- else{
+ else {
return undef;
}
}