File-KDBX
view release on metacpan or search on metacpan
lib/File/KDBX/Group.pm view on Meta::CPAN
package File::KDBX::Group;
# ABSTRACT: A KDBX database group
use warnings;
use strict;
use Devel::GlobalDestruction;
use File::KDBX::Constants qw(:bool :icon :iteration);
use File::KDBX::Error;
use File::KDBX::Iterator;
use File::KDBX::Util qw(:assert :class :coercion generate_uuid);
use Hash::Util::FieldHash;
use List::Util qw(any sum0);
use Ref::Util qw(is_coderef is_ref);
use Scalar::Util qw(blessed);
use Time::Piece 1.33;
use boolean;
use namespace::clean;
extends 'File::KDBX::Object';
our $VERSION = '0.906'; # VERSION
# has uuid => sub { generate_uuid(printable => 1) };
has name => '', coerce => \&to_string;
has notes => '', coerce => \&to_string;
has tags => '', coerce => \&to_string;
has icon_id => ICON_FOLDER, coerce => \&to_icon_constant;
has custom_icon_uuid => undef, coerce => \&to_uuid;
has is_expanded => false, coerce => \&to_bool;
has default_auto_type_sequence => '', coerce => \&to_string;
has enable_auto_type => undef, coerce => \&to_tristate;
has enable_searching => undef, coerce => \&to_tristate;
has last_top_visible_entry => undef, coerce => \&to_uuid;
# has custom_data => {};
has previous_parent_group => undef, coerce => \&to_uuid;
# has entries => [];
# has groups => [];
has times => {};
has last_modification_time => sub { gmtime }, store => 'times', coerce => \&to_time;
has creation_time => sub { gmtime }, store => 'times', coerce => \&to_time;
has last_access_time => sub { gmtime }, store => 'times', coerce => \&to_time;
has expiry_time => sub { gmtime }, store => 'times', coerce => \&to_time;
has expires => false, store => 'times', coerce => \&to_bool;
has usage_count => 0, store => 'times', coerce => \&to_number;
has location_changed => sub { gmtime }, store => 'times', coerce => \&to_time;
my @ATTRS = qw(uuid custom_data entries groups);
sub _set_nonlazy_attributes {
my $self = shift;
$self->$_ for @ATTRS, list_attributes(ref $self);
}
sub uuid {
my $self = shift;
if (@_ || !defined $self->{uuid}) {
my %args = @_ % 2 == 1 ? (uuid => shift, @_) : @_;
my $old_uuid = $self->{uuid};
my $uuid = $self->{uuid} = delete $args{uuid} // generate_uuid;
$self->_signal('uuid.changed', $uuid, $old_uuid) if defined $old_uuid;
}
$self->{uuid};
}
##############################################################################
sub entries {
my $self = shift;
my $entries = $self->{entries} //= [];
if (@$entries && !blessed($entries->[0])) {
@$entries = map { $self->_wrap_entry($_, $self->kdbx) } @$entries;
( run in 1.391 second using v1.01-cache-2.11-cpan-39bf76dae61 )