NAME

Nano::Stash - Stashable Role

ABSTRACT

Stashable Entity Role

SYNOPSIS

package Example;

use Moo;

extends 'Nano::Node';

with 'Nano::Stash';

sub bestie {
  my ($self, @args) = @_;
  return $self->stash('bestie', @args);
}

package main;

my $example = Example->new;

# $example->bestie($example);

DESCRIPTION

This package provides an entity-stashing role, useful for the ad-hoc persisting of Nano::Node entities. This role also makes it possible to save/load circularly dependent entities.

LIBRARIES

This package uses type constraints from:

Nano::Types

ATTRIBUTES

This package has the following attributes:

stashed

stashed(HashRef)

This attribute is read-only, accepts (HashRef) values, and is optional.

METHODS

This package implements the following methods:

get

get(Str $name) : Maybe[Node]

The get method finds and loads a previously stashed Nano::Node entity.

get example #1
my $example = Example->new;

my $bestie = $example->get('bestie');
get example #2
my $example = Example->new;

$example->bestie($example);
$example->save;

my $bestie = $example->get('bestie');

set

set(Str $name, Node $node) : Node

The set method stashes the Nano::Node entity provided by name. This does not save the subject or invocant.

set example #1
my $example = Example->new;

my $bestie = $example->set('bestie', $example);

stash

stash(Str $name, Maybe[Node] $node) : Maybe[Node]

The stash method will "get" or "set" a stashed Nano::Node entity based on the arguments provided.

stash example #1
my $example = Example->new;

my $bestie = $example->stash('bestie');
stash example #2
my $example = Example->new;

$example->bestie($example);
$example->save;

my $bestie = $example->stash('bestie');
stash example #3
my $example = Example->new;

my $bestie = $example->stash('bestie', $example);

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues