App-RecordStream

 view release on metacpan or  search on metacpan

lib/App/RecordStream/Deaggregator/Unarray.pm  view on Meta::CPAN

package App::RecordStream::Deaggregator::Unarray;

use strict;
use warnings;

use App::RecordStream::Deaggregator::Field;
use App::RecordStream::Deaggregator;
use App::RecordStream::DomainLanguage::Registry;

use base 'App::RecordStream::Deaggregator::Field';

sub new
{
  my $class = shift;
  my $old_field = shift;
  my $new_field = shift;

  my $this = $class->SUPER::new($old_field);

  $this->{'new_field'} = $new_field;

  return $this;
}

sub new_from_valuation
{
  my $class = shift;
  my $valuation = shift;
  my $new_field = shift;

  my $this = $class->SUPER::new_from_valuation($valuation);

  $this->{'new_field'} = $new_field;

  return $this;
}

sub deaggregate_field
{
  my $this = shift;
  my $values = shift;

  my @ret;

  for my $value (@$values)
  {
    push @ret, {$this->{'new_field'} => $value};
  }

  return \@ret;
}

sub long_usage
{
  return <<EOF;
Usage: unarray,<old field>,<new field>
   Split the array into individual \"element\" records
EOF
}

sub short_usage
{
  return "split the provided array";
}

sub argct
{
  return 2;
}

App::RecordStream::Deaggregator->register_implementation('unarray', __PACKAGE__);

App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'unarray', 'VALUATION', 'SCALAR');

1;



( run in 1.119 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )