The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::vaporcalc::Role::Store

SYNOPSIS

  # See App::vaporcalc::Recipe, App::vaporcalc::RecipeResultSet
  use Moo;
  with 'App::vaporcalc::Role::Store';

DESCRIPTION

This role provides "save" and "load" methods that attempt to serialize or retrieve objects via JSON::MaybeXS; this is used by App::vaporcalc::Recipe & App::vaporcalc::RecipeResultSet to preserve e-liquid recipes.

REQUIRES

TO_JSON

Consumers are expected to implement a TO_JSON method that returns a plain HASH for storage.

METHODS

save

Takes a path (as a string or a Path::Tiny object) and attempts to serialize the $self object to the given path.

Objects are expected to provide their own TO_JSON method; if it is not available, an exception is thrown.

load

Takes a path (as a string or a Path::Tiny object) and attempts to create a new object by calling new().

(Usually called as a class method.)

AUTHOR

Jon Portnoy <avenj@cobaltirc.org>