=pod

=head1 NAME

Object::By::Scalar - minimalistic constructors for scalar based objects

=head1 SYNOPSIS

	package some_package;
	use parent qw(Object::By::Scalar);

	sub _init {
		my ($self) = @_;
		$$self = data of the only attribute;
		...
		return;
	}

	package main;
	use some_package;
	some_package->new(...);

=head1 DESCRIPTION

Object::By::Scalar provides generic constructors for OO programming, which are tailored to an actual class via a method called _init. A generic constructor creates the reference from various sources, blesses, tailors, and finally returns it. A small advantage at a small price of 60 lines of Perl code.

Warning: unlike for arrays and hashes there is no locking for scalars.

=head1 METHOD REFERENCE (API)

The design goal was a simple and robust API with a straightforward implementation, respecting all limitations of Perl 5.

=over 8

=item new

The generic constructor for the classic call class->new. If the method _init is defined, calls _init and forwards any arguments to it.

=item _init

A standard tailoring, which stores the scalar value of first argument to new() as the scalar value.

=item same

A generic constructor for the call $object->new'. Otherwise works like new.

=item prototype

A generic constructor for the call $object->new'. However, this creates an empty (and potentially useless) prototype object.

=item clone

A generic constructor for the call $object->new'. However, it does not call the method _init, but copies the first level of the object's data structure. To leave no doubt: no deep copy is performed.

=back


=head1 KNOWN BUGS AND LIMITATIONS

This is the first public release.

=head1 AUTHOR

Winfried Trumper E<lt>pub+perl(a)wt.tuxomania.netE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2011 Winfried Trumper

This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut
