
package Text::Wigwam::Engine::Common::Bugs;

    use strict;
    use warnings;
    our $VERSION = '0.01';

sub new {
    my ($class, $strict) = @_;
    return bless {
        BUGS => [],
        FATAL => 0,
        STRICT => $strict || 0
    }, ref($class) || $class;
}

sub _bugs { $_[0]->{BUGS} }
sub _strict{ $_[0]->{STRICT} }
sub _fatal {
    my ($self, $flag) = @_;
    return $self->{FATAL} ||= $flag;
}

sub warning {
    my ($self, $bug, $addr) = @_;
    push( @{$self->{BUGS}}, [ $bug, $addr ] );
}

sub fatal {
    my ($self, $bug, $addr) = @_;
    $self->_fatal(1);
    push( @{$self->{BUGS}}, [ $bug, $addr ] );
}

sub list { @{$_[0]->{BUGS}} }

#sub is_fatal { return scalar @{$_[0]->{BUGS}} ? 1 : 0 }
sub is_fatal {
    my ($self) = @_;
    return $self->_strict ? scalar $self->list ? 1 : 0
                          : $self->_fatal;
}

1;
