package Person;
use Bubblegum::Class;
use Bubblegum::Syntax -all;
has id => (is => 'ro', isa => typeof_int);
has firstname => (is => 'ro', isa => typeof_str);
has lastname => (is => 'ro', isa => typeof_str);
has object => (
is => 'ro',
isa => typeof_object,
lazy => 1
);
if (not_int $var) {
raise arger => 'this should be working';
}
sub say_hello {
my $self = shift;
my $title = type_str shift;
my $params = type_href shift // {};
raise 'last_name is required'
unless $self->last_name;
return type_str join ', ',
$self->last_name->titlecase,
$self->first_name->titlecase // ()
}
package main;
my $dude = Person->new(firstname => 'Doodie');
$dude->say_hello;
1;
Hardcore Perl hackers around the world are working tirelessly around the clock
to give us a better system for elegantly defining objects and classes using
modern Perl best practices, ... but in the meantime, have some Bubblegum.
# BETTER HAS ACCESSOR BUILDER
use Bubblegum::Syntax -attr
has [NAME];
has [NAME], DEFAULT;
has TYPE, [NAME];
has TYPE, [NAME], DEFAULT;
# CLEANUP THE CONFIGURATION CLASS
# MOVE ENVIRONMENT FUNCTIONS INTO THE SYNTAX CLASS
# COERCION FUNCTIONALITY ACROSS ROLES
use Bubblegum::Syntax -coerce;
1 + '';
[] + [1];
{} + {};
# FODDER, FODDER, FODDER
I started wondering ... "is there a word which is the opposite of (not)". I'm
not sure this stands to reason but at first I thought it might be (is) but in
common speech the opposite of (is) is (isn't) which is a contraction and not
technically an opposite, which lead me to (are) but the same logic applies just
as with (is) and the contracted opposite of (are) is (aren't); then it occurred
to me that (aren't) is the contraction of (are not) which lead me to believe the
opposite of (not) is (so). I have no idea what I'm talking about, is this correct?
use Bubblegum::Syntax -utils;
# read the contents of the config, send it to the yaml serializer and decode it
my $app_config = type_href file('./config.yml')->yaml->decode;
my $env_config = type_href file('./environment/config.yml')->yaml->decode;
my $config = type_href merge $main_config, $env_other;
# Bubblegum and Booby Traps
# ... or Validation, Interfaces, and Method Signatures