I couldn't find an example in the docs of how to set up
Rose::DB::Object::Loader with a properly pluralizing convention manager.
I tried the following, but I keep getting a class called "Currencie"
from a table called "currencies" for example. I must be missing
something.
Ted
package My::DB::Metadata;
use Rose::DB::Object::Metadata;
our @ISA = qw(Rose::DB::Object::Metadata);
use Lingua::EN::Inflect;
sub init_convention_manager
{
my $self = shift;
# Let the base class make ths convention manager object
my $cm = $self->SUPER::init_convention_manager(@_);
# Set the new singular-to-plural function
$cm->singular_to_plural_function(\&Lingua::EN::Inflect::PL);
# Return the modified convention manager
return $cm;
}
1;
package My::DB::Thunder::BaseObject;
use My::DB::DB;
use My::DB::Metadata;
use Rose::DB::Object::Loader;
use Rose::DB::Object::Helpers qw/load_or_insert load_speculative
column_values_as_yaml column_values_as_json/;
use base qw(Rose::DB::Object);
sub meta_class { 'My::DB::Metadata' }
sub generate_classes
{
my ($class, $environment, $type) = @_;
$environment ||= 'production';
$type ||= 'thunder';
My::DB::DB->default_domain($environment);
my $class_prefix = $class;
$class_prefix =~ s/[^:]+$//; # remove our class name and
keep the package plus '::'
print "Running with class prefix $class_prefix environment $environment type
$type\n";
my $loader =
Rose::DB::Object::Loader->new(db => My::DB::DB->new(type=>$type),
base_class => $class,
convention_manager =>
My::DB::Metadata->init_convention_manager(),
class_prefix => $class_prefix);
@classes = $loader->make_modules();
}
1;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object