Server IP : 85.214.239.14 / Your IP : 18.221.248.140 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /usr/share/perl5/Mail/SPF/ |
Upload File : |
# # Mail::SPF::Base # Base class for Mail::SPF classes. # # (C) 2005-2012 Julian Mehnle <julian@mehnle.net> # 2005 Shevek <cpan@anarres.org> # $Id: Base.pm 57 2012-01-30 08:15:31Z julian $ # ############################################################################## package Mail::SPF::Base; =head1 NAME Mail::SPF::Base - Base class for Mail::SPF classes =cut use warnings; use strict; use Error ':try'; use Mail::SPF::Exception; use constant TRUE => (0 == 0); use constant FALSE => not TRUE; =head1 SYNOPSIS use base 'Mail::SPF::Base'; sub new { my ($class, @options) = @_; my $self = $class->SUPER::new(@options); ... return $self; } =head1 DESCRIPTION B<Mail::SPF::Base> is a common base class for all B<Mail::SPF> classes. =head2 Constructor The following constructor is provided: =over =item B<new(%options)>: returns I<Mail::SPF::Base> Creates a new object of the class on which the constructor was invoked. The provided options are stored as key/value pairs in the new object. The C<new> constructor may also be called on an object, in which case the object is cloned. Any options provided override those from the old object. There are no common options defined in B<Mail::SPF::Base>. =cut sub new { my ($self, %options) = @_; my $new = ref($self) ? # Was new() invoked on a class or an object? { %$self, %options } # Object: clone source object, override fields. : \%options; # Class: create new object. return bless($new, $self->class); } =back =head2 Class methods The following class methods are provided: =over =item B<class>: returns I<string> Returns the class name of the class or object on which it is invoked. =cut sub class { my ($self) = @_; return ref($self) || $self; } =back =head2 Class methods The following class methods are provided: =over =item B<make_accessor($name, $readonly)>: returns I<code-ref> Creates an accessor method in the class on which it is invoked. The accessor has the given name and accesses the object field of the same name. If $readonly is B<true>, the accessor is made read-only. =cut sub make_accessor { my ($class, $name, $readonly) = @_; throw Mail::SPF::EClassMethod if ref($class); my $accessor_name = "${class}::${name}"; my $accessor; if ($readonly) { $accessor = sub { local *__ANON__ = $accessor_name; my ($self, @value) = @_; throw Mail::SPF::EInstanceMethod if not ref($self); throw Mail::SPF::EReadOnlyValue("$accessor_name is read-only") if @value; return $self->{$name}; }; } else { $accessor = sub { local *__ANON__ = $accessor_name; my ($self, @value) = @_; throw Mail::SPF::EInstanceMethod if not ref($self); $self->{$name} = $value[0] if @value; return $self->{$name}; }; } { no strict 'refs'; *{$accessor_name} = $accessor; } return $accessor; } =back =head2 Instance methods There are no common instance methods defined in B<Mail::SPF::Base>. =head1 SEE ALSO L<Mail::SPF> For availability, support, and license information, see the README file included with Mail::SPF. =head1 AUTHORS Julian Mehnle <julian@mehnle.net>, Shevek <cpan@anarres.org> =cut TRUE;