Business-CompanyDesignator

 view release on metacpan or  search on metacpan

lib/Business/CompanyDesignator/Record.pm  view on Meta::CPAN

package Business::CompanyDesignator::Record;

use Moose;
use utf8;
use warnings qw(FATAL utf8);
use Carp;
use namespace::autoclean;

has 'long'                  => ( is => 'ro', isa => 'Str', required => 1 );
has 'record'                => ( is => 'ro', isa => 'HashRef', required => 1 );

has [qw(abbr1 lang)]        => ( is => 'ro', lazy_build => 1 );
has 'abbr'                  => ( is => 'ro', isa => 'ArrayRef[Str]', lazy => 1, builder => '_build_abbr',
                                 reader => '_abbr', traits => [ qw(Array) ], handles => { abbr => 'elements' } );

sub _build_abbr {
  my $self = shift;
  my $abbr_std = $self->record->{abbr_std};
  my $abbr = $self->record->{abbr} || [];
  $abbr = [ $abbr ] if ! ref $abbr;
  push @$abbr, $abbr_std if $abbr_std;
  return $abbr;
}

sub _build_abbr1 {
  my $self = shift;
  my @abbr = $self->abbr;
  if (@abbr) {
    return $abbr[0];
  }
}

sub _build_lang {
  my $self = shift;
  $self->record->{lang};
}

__PACKAGE__->meta->make_immutable;

1;

=head1 NAME

Business::CompanyDesignator::Record - class for modelling individual L<Business::CompanyDesignator> input records

=head1 SYNOPSIS

  # Typically instantiated via Business::CompanyDesignator->record() or records()
  use Business::CompanyDesignator;
  
  $bcd = Business::CompanyDesignator->new;
  $record = $bcd->record("Limited");
  @records = $bcd->records("Inc.");

  # Accessors
  $long = $record->long;
  @abbr = $record->abbr;
  $abbr1 = $record->abbr1;
  $lang = $record->lang;

=head1 METHODS

=head2 new()

Create a new Business::CompanyDesignator::Record object.

B<Note:> objects are normally instantiated via Business::CompanyDesignator->record()



( run in 1.959 second using v1.01-cache-2.11-cpan-5a3173703d6 )