Fukurama::Class::Version - Pragma to set package-version


Fukurama-Class documentation Contained in the Fukurama-Class distribution.

Index


Code Index:

NAME

Top

Fukurama::Class::Version - Pragma to set package-version

VERSION

Top

Version 0.02 (beta)

SYNOPSIS

Top

 package MyClass;
 use Fukurama::Class::Version('1.10');

DESCRIPTION

Top

This pragma-like module provides a set method for package version. It check the correctness of version-value at compiletime. Use Fukurama::Class instead, to get all the features for OO.

CONFIG

Top

-

EXPORT

Top

$YourClass::VERSION : this global variable would be set at compiletime.

METHODS

Top

version( version:DECIMAL ) return:BOOLEAN

Helper-method, which would executed by every pragma usage.

AUTHOR, BUGS, SUPPORT, ACKNOWLEDGEMENTS, COPYRIGHT & LICENSE

Top

see perldoc of Fukurama::Class


Fukurama-Class documentation Contained in the Fukurama-Class distribution.

package Fukurama::Class::Version;
our $VERSION = 0.02;
use Fukurama::Class::Rigid;
use Fukurama::Class::Carp;

# AUTOMAGIC void
sub import {
	my $class = $_[0];
	my $version = $_[1];
	
	my ($caller_class) = caller(0);
	$class->version($caller_class, $version, 1);
	return undef;
}
# boolean
sub version {
	my $class = $_[0];
	my $caller_class = $_[1];
	my $version = $_[2];
	my $import_depth = $_[3] || 0;
	
	if(!defined($version)) {
		_croak("Try to set undefined version to class '$caller_class'", $import_depth);
	} elsif($version !~ /^[0-9]+(?:[\._]?[0-9]+)*$/) {
		_croak("Try to set non-decimal version '$version' to class '$caller_class'", $import_depth);
	}
	
	no strict 'refs';
	
	${"$caller_class\::VERSION"} = $version;
	return 1;
}
1;