NAME

Astro::App::Satpass2::Copier - Object copying functionality for Astro::App::Satpass2

SYNOPSIS

package Astro::App::Satpass2::Foo;

use strict;
use warnings;

use parent qw{ Astro::App::Satpass2::Copier };

sub new { ... }

sub attribute_names {
    return ( qw{ bar baz } );
}

__PACKAGE__->create_attribute_methods();

1;

DETAILS

This class is private to the Astro::App::Satpass2 package. The author reserves the right to modify it in any way or retract it without prior notice.

METHODS

This class supports the following public methods:

Accessors and Mutators

warner

$obj->warner( undef );
my $warner = $obj->warner();

This method is both accessor and mutator for the warner attribute.

If an argument is passed, it must be either an Astro::App::Satpass2::Warner (either class or object), or undef (which causes a new Astro::App::Satpass2::Warner object to be created.)

If no argument is passed, it is an accessor, returning the warner object. If no such object has been assigned, one will be generated.

attribute_names

print join( ', ', $obj->attribute_names() ), "\n";

This method returns the names of the object's attribute_names.

Subclasses should override this. Immediate subclasses should call SUPER::attribute_names(), and indirect subclasses must call SUPER::attribute_names(). A subclass' override would look something like this:

sub attribute_names {
    my ( $self ) = @_;
    return ( $self->SUPER::attribute_names(), qw{ foo bar baz } );
}

class_name_of_record

say 'I am a ', $obj->class_name_of_record();

This method returns the class name of record of the object. By default this is simply the name of the object's class (i.e. ref $obj, but subclasses can override this to hide implementation details.

clone

my $clone = $obj->clone();

This method returns a clone of the original object, taken using Clone::clone().

Overrides may call SUPER::clone(). If they do not they bear complete responsibility for producing a correct clone of the original object.

copy

$obj->copy( $copy, %skip );

This method copies the attribute values of the original object into the attribute_names of the copy object. The original object is returned.

The %skip hash is optional. Any attribute that appears in the %skip hash is skipped. Note that you can also pass an array here provided it has an even number of elements; the even-numbered elements (from zero) will be taken as the attribute names.

The copy object need not be the same class as the original, but it must support all attributes the original supports.

create_attribute_methods

__PACKAGE__->create_attribute_methods();

This method may be called exactly once by the subclass to create accessor/mutator methods. This method assumes that the object is based on a hash reference, and stores attribute values in same-named keys in the hash. The created methods have the same names as the attributes. They are accessors if called without arguments, and mutators returning the original object if called with arguments. Methods already in existence when this method is called will not be overridden.

init

$obj->init( name => value ... );

This method sets multiple attributes. It dies if any of the names does not represent a legal attribute name. It returns the invocant.

Other Methods

wail

$self->wail( 'Something bad happened' );

This convenience method simply wraps $self->warner()->wail().

weep

$self->weep( 'Something really horrible happened' );

This convenience method simply wraps $self->warner()->weep().

whinge

$self->whinge( 'Something annoying happened' );

This convenience method simply wraps $self->warner()->whinge().

SUPPORT

Support is by the author. Please file bug reports at https://rt.cpan.org/Public/Dist/Display.html?Name=Astro-App-Satpass2, https://github.com/trwyant/perl-Astro-App-Satpass2/issues, or in electronic mail to the author.

AUTHOR

Thomas R. Wyant, III wyant at cpan dot org

COPYRIGHT AND LICENSE

Copyright (C) 2010-2023 by Thomas R. Wyant, III

This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.