I wrote the Sledge::Plugin::CreateConfig for Sledge2.0.This module generates crete_config method automatically.
package Sledge::Plugin::CreateConfig; use strict; use warnings; our $VERSION = 0.01; use Carp; use Sledge::Utils; use UNIVERSAL::require;
sub import { my $pkg = caller(0);
my $config_class = Sledge::Utils::class2appclass($pkg); $config_class .= '::Config';
$config_class->use or die $@;
no strict 'refs'; *{"$pkg\::create_config"} = sub { my $self = shift; return $config_class->instance; }; }
1;
package Your::Pages; use base qw/Sledge::Pages::Compat/;
use Your::Config; sub create_config { Your::Config->instance; }
package Your::Pages; use base qw/Sledge::Pages::Compat/; use Sledge::Plugin::CreateConfig;
Re:is it verbose?
tokuhirom on 2006-11-01T07:54:08
Ah, my company don't have a helper script orz. Please release, ikebe-san!!Re:is it verbose?
tokuhirom on 2006-11-01T08:14:16
and ah, I'll write Module::Starter::Sledge(naming is...). Re:is it verbose?
miyagawa on 2006-11-01T08:29:27
No, I meant sledge-setup script which is in CVS.Re:is it verbose?
tokuhirom on 2006-11-01T08:37:10
Ah, I don't use this. and, My first impression of Sledge, Proj::Pages::Base is too complex.
Proj::Pages::Foo contains many follow codes.I want to short that.use Sledge::Foo::Bar;
sub create_foo {
my $self;
Sledge::Foo::Bar->new($self);
}Re:is it verbose?
miyagawa on 2006-11-01T08:49:02
I agree it's verbose but don't agree it's "complex." I didn't care that much since it could be auto-generated and the code is still there if you want to override the behavior, say, to replace MySQL with PgSQL for session storage.Re:is it verbose?
tokuhirom on 2006-11-01T09:11:45
Sorry, OK sure, that's no 'complex'.