package Daje::Workflow::Savefile::Activity;
use Mojo::Base 'Daje::Workflow::Common::Activity::Base', -base, -signatures;


# NAME
# ====
#
# Daje::Workflow::Savefile::Activity - It's tool to save a n array of files
#
# SYNOPSIS
# ========
#
#     use Daje::Workflow::Savefile::Activity;
#
# DESCRIPTION
# ===========
#
# Daje::Workflow::Savefile::Activity is a file saver
#
# LICENSE
# =======
#
# Copyright (C) janeskil1525.
#
# This library is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
# AUTHOR
# ======
#
# janeskil1525 E<lt>janeskil1525@gmail.comE<gt>
#

use Mojo::File;

our $VERSION = "0.01";

sub save($self) {

    eval {
        my $filepath = $self->context->{context}->{sql_target_dir};
        my $files = $self->context->{context}->{sql};
        my $length = scalar @{$files};
        for (my $i = 0; $i < $lenght; $i++) {
            my $file = $filepath . @{$files}[$i]->{file} . $self->activity_data->{file}->{filetype};
            open(my $fh, ">", $file);
            print $fh @{$files}[$i]->{data};
            close $fh;
        }
    };
    $self->error->add_error($@) if defined $@ and length($@) > 0;

    return;
}

1;
__END__



#################### pod generated by Pod::Autopod - keep this line to make pod updates possible ####################

=head1 NAME


Daje::Workflow::Savefile::Activity - It's tool to save a n array of files



=head1 SYNOPSIS


    use Daje::Workflow::Savefile::Activity;



=head1 DESCRIPTION


Daje::Workflow::Savefile::Activity is a file saver



=head1 REQUIRES

L<Mojo::File> 

L<Mojo::Base> 


=head1 METHODS

=head2 save($self)

 save($self)();


=head1 AUTHOR


janeskil1525 E<lt>janeskil1525@gmail.comE<gt>



=head1 LICENSE


Copyright (C) janeskil1525.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.



=cut

