Config::Tiny::Singleton - singleton-pattern implementation for Config::Tiny


Config-Tiny-Singleton documentation  | view source Contained in the Config-Tiny-Singleton distribution.

Index


NAME

Top

Config::Tiny::Singleton - singleton-pattern implementation for Config::Tiny

SYNOPSIS

Top

	package MyProj::Config;
	use base qw/Config::Tiny::Singleton/;
	__PACKAGE__->file('/your/project/conf.file');
	1;

	package main;
	use MyProj::Config;

	my $var = MyProj::Config->instance->{section1}{key1};
	...

	# and in another package,

	package MyProj::Hoge;
	use MyProj::Config;
	my $var2 = MyProj::Config->instance->{section2}{key2};

DESCRIPTION

Top

You may make many modules and some config-files when you build large applications. There are several ways to handle configs. One is to create new config-object in each packages that need data set in config-files. However, this will make your app's performance pretty bad. Second is to let your context-object to keep your config-object. But your application become larger and larger, it'll be too hard to let your context to handle all configs. And third is, this is better, to implement singleton-pattern. Try that, and now you only need to call your configs instance method in your package where you want to use it in.

SEE ALSO

Top

Config::Tiny, Class::Singleton

AUTHOR

Top

Lyo Kato <kato@lost-season.jp>

COPYRIGHT AND LICENSE

Top


Config-Tiny-Singleton documentation  | view source Contained in the Config-Tiny-Singleton distribution.