package Daje::Plugin::Output::Class;
use Mojo::Base -base, -signatures;

use Mojo::File;
use String::CamelCase qw(camelize);

our $VERSION = '0.01';

has 'config' ;
has 'table_name';
has 'perl' ;
has 'name_space_dir';

sub save_file($self) {

    my $filename = $self->_create_new_filename();
    eval {
        open (my $fh, ">", $filename) or die "Could not open file '$filename";
        print $fh $self->perl();
        close $fh;
    };
    die "Daje::Plugin::Output::Class::save_file '$@'" if $@;

    return;
}

sub _create_new_filename($self) {
    my $filename;

    eval {
        $filename = $self->config->{PATH}->{$self->name_space_dir()} . camelize($self->table_name()) . ".pm";
    };
    die "Daje::Plugin::Output::Class::create_new_filename failed '$@'" if $@;

    return $filename;
}
1;
#################### pod generated by Pod::Autopod - keep this line to make pod updates possible ####################

=head1 NAME

Daje::Plugin::Output::Class


=head1 REQUIRES

L<String::CamelCase> 

L<Mojo::File> 

L<Mojo::Base> 


=head1 METHODS

=head2 save_file($self)

 save_file($self)();


=cut

