NAME
Nano::Nodes - Persistable Index
ABSTRACT
Persistable Index Super Class
SYNOPSIS
use Nano::Nodes;
my $nodes = Nano::Nodes->new(
type => 'Nano::Node',
);
# $nodes->save;
DESCRIPTION
This package provides a persistable index super class. It is meant to be subclassed but can be used directly as well.
INHERITS
This package inherits behaviors from:
LIBRARIES
This package uses type constraints from:
ATTRIBUTES
This package has the following attributes:
orders
orders(ArrayRef[CodeRef])
This attribute is read-only, accepts (ArrayRef[CodeRef])
values, and is optional.
scopes
scopes(ArrayRef[CodeRef])
This attribute is read-only, accepts (ArrayRef[CodeRef])
values, and is optional.
type
type(Str)
This attribute is read-only, accepts (Str)
values, and is required.
METHODS
This package implements the following methods:
add
add(HashRef $data) : Object
The add method creates a new object, adds it to the index, and returns the created object.
all
all() : ArrayRef[Object]
The all method proxies to the attached Nano::Search instance and returns the results.
count
count() : Int
The count method proxies to the attached Nano::Search instance and returns the results.
drop
drop() : Object
The drop method deletes the entire index and all of its indices.
first
first() : Maybe[Object]
The first method proxies to the attached Nano::Search instance and returns the result.
get
get(Str $name) : Maybe[Object]
The get method returns the object (based on ID) from the index (if found).
last
last() : Maybe[Object]
The last method proxies to the attached Nano::Search instance and returns the result.
order
order(CodeRef $callback) : Object
The order method registers a sort order (search ordering) and returns a new invocant instance.
- order example #1
-
# given: synopsis $nodes = $nodes->order(sub { my ($a, $b) = @_; $a->id cmp $b->id });
scope
scope(CodeRef $callback) : Object
The scope method registers a scope (search filter) and returns a new invocant instance.
- scope example #1
-
# given: synopsis $nodes = $nodes->scope(sub { my ($node) = @_; !!$node->{active} });
search
search() : Search
The search method returns a Nano::Search object associated with the invocant.
serialize
serialize() : HashRef
The serialize method returns a persistence representaton of the invocant. Circular dependencies can result in a deep recursion error, however, circular dependencies can be persisted if modeled properly. Note: blessed objects which are neither Nano::Node nor Nano::Nodes will be ignored.
set
set(Node $object) : Object
The set method adds the node object provided to the index and returns the provided object.
- set example #1
-
# given: synopsis use Nano::Node; my $node = Nano::Node->new(id => '0000003'); $node = $nodes->set($node);
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".