Here's something to play with. I used
Moo.
package Lounge::Table;
use strict;
use warnings;
use Moo;
use Sub::Quote;
print "\n";
print "|The Lounge|\n";
sub table {
my $self = shift;
my $table_type = shift || 1;
$self->wood( $self->wood - $table_type );
}
has bench => (
is => 'ro',
);
has type => (
is => 'ro',
isa => sub {
die "lounge table $!\n" unless $_[0] eq 'lounge_table'
},
);
has wood => (
is => 'ro',
isa => quote_sub q{
die "$_[0] isn't littered with text from computers!\n"
unless "$_[0] is littered with text from computers!\n" },
);
1;
my $sit_down_at = Lounge::Table->new(
bench => 'comfortable',
type => 'wood',
table => 'littered with text from computers',
);
$sit_down_at->lounge_table;
say $sit_down_at->table;