$self->flavor_total }
method TO_JSON {
+{
map {;
my ($attr, $val) = ($_, $self->$_);
my $raw = blessed $val && $val->can('TO_JSON') ? $val->TO_JSON : $val;
$attr => $raw
flavors
/,
}
}
with 'App::vaporcalc::Role::Store';
1;
=pod
=for Pod::Coverage TO_JSON
=head1 NAME
App::vaporcalc::Result - A calculated App::vaporcalc::Recipe result
=head1 SYNOPSI
calc::Cmd::Result->new(%params)
}
method munge_recipe (%params) {
my $data = $self->recipe->TO_JSON;
$data->{$_} = $params{$_} for keys %params;
App::vaporcalc::Recipe->new(%$data)
}
1;
=pod
y $new_recipe = $self->munge_recipe(
target_vg => 50,
target_pg => 50
);
Calls C<TO_JSON> on the current L</recipe> object, merges in the
given key/value pairs, and returns a new L<App::
d TO_JSON {
+{
percentage => $self->percentage,
tag => $self->tag,
type => $self->type,
}
}
with 'App::vaporcalc::Role::Store';
1;
=pod
=for Pod::Coverage TO_JSON
=he
}
}
\%params
}
method TO_JSON {
+{
map {;
my ($attr, $val) = ($_, $self->$_);
my $raw = blessed $val && $val->can('TO_JSON') ? $val->TO_JSON : $val;
$attr => $raw
ole::Calc',
'App::vaporcalc::Role::Store' ;
1;
=pod
=for Pod::Coverage BUILD BUILDARGS TO_JSON
=head1 NAME
App::vaporcalc::Recipe - An e-liquid recipe
=head1 SYNOPSIS
use App::vaporcalc:
= '0.005004';
use Defaults::Modern;
use JSON::MaybeXS 1.001 ();
use Role::Tiny;
requires 'TO_JSON';
method save ( (Str | Path) $path ) {
my $jseng = JSON::MaybeXS->new(
utf8 => 1,
1,
);
my $json = $jseng->encode($self)
|| confess "Could not encode JSON: ".$jseng->error;
path($path)->spew_utf8($json)
}
method load ( (Str | Path) $path ) {
my $json = path($path)
->slurp_utf8;
my $jseng = JSON::MaybeXS->new(
utf8 => 1,
relaxed => 1,
);
my $data = $jseng->decode($json)
|| confess "Could not decode JSON: ".$jseng->error;
$self->_loa
sub { shift->recipe->calc },
);
method TO_JSON {
+{ recipe => $self->recipe }
}
with 'App::vaporcalc::Role::Store';
1;
=pod
=for Pod::Coverage TO_JSON
=head1 NAME
App::vaporcalc::RecipeResult