blib/lib/Class/Meta/Constructor.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
condition | 24 | 35 | 68.5 |
line | !l | l&&!r | l&&r | condition |
---|---|---|---|---|
108 | 0 | 0 | 1 | $ref and $ref eq 'CODE' |
119 | 1 | 0 | 0 | $ref and $ref eq 'CODE' |
line | l | !l | condition |
---|---|---|---|
331 | 1 | 24 | delete $$self{'code'} || sub { my $package = ref $_[0] ? ref shift() : shift(); my $class = $$specs{$package}; $class->handle_error("Cannot construct objects of astract class $package") if $class->abstract; my $sub = @_ % 2 && ref $_[-1] eq 'CODE' ? pop @_ : undef; my(%p) = @_; my $new = bless({}, $package); my @req; if (my $attrs = $$class{'attrs'}) { foreach my $attr (@{$attrs;}{@{$$class{'all_attr_ord'};}}) { next if $attr->context == 1; my $key = $attr->name; if (exists $p{$key} and $attr->authz >= 3) { $attr->set($new, delete $p{$key}); } elsif (not exists $$new{$key}) { $$new{$key} = $attr->default; push @req, $attr if $attr->required; }; }; }; if (my(@attributes) = keys %p) { my $c = $#attributes > 0 ? 'attributes' : 'attribute'; local $" = q[', ']; $class->handle_error("No such $c '@{attributes}' in $$self{'package'} objects"); }; &$sub($new) if $sub; if (@req and my(@miss) = grep({not defined $$new{$_->name};} @req)) { my $c = $#miss > 0 ? 'Attributes' : 'Attribute'; my $a = join(q[', '], map({$_->name;} @miss)); $class->handle_error("$c '${a}' must be defined in $$self{'package'} objects"); }; return $new; } |
line | l | !l&&r | !l&&!r | condition |
---|---|---|---|---|
66 | 39 | 1 | 2 | UNIVERSAL::isa($caller, 'Class::Meta') or UNIVERSAL::isa($caller, 'Class::Meta::Constructor') |
87 | 2 | 0 | 34 | exists $$class{'ctors'}{$p{'name'}} or exists $$class{'meths'}{$p{'name'}} |
95 | 2 | 1 | 6 | $p{'view'} == 4 or $p{'view'} == 2 |
3 | 1 | 5 | $p{'view'} == 4 or $p{'view'} == 2 or $p{'view'} == 3 | |
2 | 2 | 3 | $p{'view'} == 4 or $p{'view'} == 2 or $p{'view'} == 3 or $p{'view'} == 1 | |
128 | 0 | 30 | 0 | ref $pkg || $pkg |
260 | 25 | 0 | 1 | UNIVERSAL::isa($caller, 'Class::Meta') or UNIVERSAL::isa($caller, 'Class::Meta::Constructor') |
266 | 24 | 1 | 0 | delete $$self{'create'} or $$self{'code'} |
355 | 0 | 25 | 0 | $$self{'caller'} ||= $sub |