| 1 | package Venus::Role::Unacceptable; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use 5.018; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | # IMPORTS | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | ▶ | use Venus::Role 'raise'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | # BUILDERS | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 1 | ▶ | sub BUILD { | ||||||||||||||||||
|
Subroutine
BUILD: called CC=3 SCAR=12.3
Pod
undocumented
| |||||||||||||||||||||
| 15 | 1 | my ($self) = @_; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||
| 18 | 1 | my %attrs = map +($_, $_), $self->META->attrs; | |||||||||||||||||||
| 19 | 1 | my @unknowns = sort grep !exists($attrs{$_}), keys %$self; | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 1 | ▶ | raise 'Venus::Role::Unacceptable::Error', { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | name => 'on.build', | ||||||||||||||||||||
| 23 | stash => {unknowns => [@unknowns]}, | ||||||||||||||||||||
| 24 | message => "$class was passed unknown attribute(s): " . join ', ', | ||||||||||||||||||||
| 25 | map "'$_'", @unknowns, | ||||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | if @unknowns; | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 0 | return $self; | |||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 1 | 1; | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | =head1 NAME | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | Venus::Role::Unacceptable - Unacceptable Role | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | =cut | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | =head1 ABSTRACT | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | Unacceptable Role for Perl 5 | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | =cut | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | =head1 SYNOPSIS | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | package ExampleAccept; | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | use Venus::Class 'attr'; | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | attr 'name'; | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | package ExampleDeny; | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | use Venus::Class 'attr', 'with'; | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | with 'Venus::Role::Unacceptable'; | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | attr 'name'; | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | package main; | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | my $example = ExampleDeny->new(name => 'example', test => 12345); | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | # Exception! (isa Venus::Role::Unacceptable::Error) | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | =cut | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | =head1 DESCRIPTION | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | This package provides a mechanism for raising an exception when unexpected | ||||||||||||||||||||
| 75 | constructor arguments are encountered. | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | =cut | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | =head1 AUTHORS | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | Awncorp, C<awncorp@cpan.org> | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | =cut | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | =head1 LICENSE | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>. | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | This program is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||
| 90 | the terms of the Apache license version 2.0. | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | =cut | ||||||||||||||||||||