Image-Synchronize

 view release on metacpan or  search on metacpan

lib/Image/Synchronize/GroupedInfo.pm  view on Meta::CPAN

package Image::Synchronize::GroupedInfo;

use Modern::Perl;

use overload '""' => \&stringify;

use Carp;

=head1 NAME

Image::Synchronize::GroupedInfo - a data collection in support of
Image::Synchronize

=cut

=head1 METHODS

=head2 new

  $egi = new Image::Synchronize::GroupedInfo;

Create a new instance of the class.

=cut

sub new {
  my ($class) = @_;
  return bless {}, $class;
}

=head2 set

  $egi->set($tag, $value);
  $egi->set($group, $tag, $value);

Associated the C<$value> with the C<$tag> and (optionally) C<$group>.
The C<$group> and C<$tag> must be scalars, but the C<$value> may be of
any type.  Returns C<$egi>.

=cut

sub set {
  my $self = shift;
  my ( $group, $tag, $value );
  if ( scalar(@_) == 3 ) {
    ( $group, $tag, $value ) = @_;
  }
  elsif ( scalar(@_) == 2 ) {
    ( $tag, $value ) = @_;
  }
  else {
    croak "Expected tag and value, or group, tag, and value.";
  }
  if ( defined $value ) {
    $self->{$tag}->{ $group // '' } = $value;
  }
  else {    # delete
    if ( defined $group ) {
      $self->delete( $group, $tag );
    }
    else {
      $self->delete($tag);
    }



( run in 1.552 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )