Data-Hive
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Data/Hive.pm view on Meta::CPAN
#pod
#pod =cut
sub NEW {
my ($invocant, $arg) = @_;
$arg ||= {};
my @path = @{ $arg->{path} || [] };
my $class = ref $invocant ? ref $invocant : $invocant;
my $self = bless { path => \@path } => $class;
if ($arg->{store_class}) {
die "don't use 'store' with 'store_class' and 'store_args'"
if $arg->{store};
$arg->{store_class} = "Data::Hive::Store::$arg->{store_class}"
unless $arg->{store_class} =~ s/^[+=]//;
$self->{store} = $arg->{store_class}->new(@{ $arg->{store_args} || [] });
} elsif ($arg->{store}) {
lib/Data/Hive/PathPacker/Flexible.pm view on Meta::CPAN
unescape => $arg->{unescape} || sub {
my ($self, $str) = @_;
$str =~ s/%([0-9a-f]{2})/chr(hex($1))/ge;
return $str;
},
join => $arg->{join} || sub { join $_[0]{separator}, @{$_[1]} },
split => $arg->{split} || sub { split /\Q$_[0]{separator}/, $_[1] },
};
return bless $guts => $class;
}
sub pack_path {
my ($self, $path) = @_;
my $escape = $self->{escape};
my $join = $self->{join};
return $self->$join([ map {; $self->$escape($_) } @$path ]);
}
lib/Data/Hive/PathPacker/Strict.pm view on Meta::CPAN
#pod =cut
sub new {
my ($class, $arg) = @_;
$arg ||= {};
my $guts = {
separator => $arg->{separator} || '.',
};
return bless $guts => $class;
}
sub pack_path {
my ($self, $path) = @_;
my $sep = $self->{separator};
my @illegal = grep { /\Q$sep\E/ } @$path;
Carp::confess("illegal hive path parts: @illegal") if @illegal;
lib/Data/Hive/Store/Hash.pm view on Meta::CPAN
$arg = {} unless $arg;
my $guts = {
store => $href,
path_packer => $arg->{path_packer} || do {
require Data::Hive::PathPacker::Strict;
Data::Hive::PathPacker::Strict->new;
},
};
return bless $guts => $class;
}
#pod =method hash_store
#pod
#pod This method returns the hashref in which things are being used. You should not
#pod alter its contents!
#pod
#pod =cut
sub hash_store { $_[0]->{store} }
lib/Data/Hive/Store/Hash/Nested.pm view on Meta::CPAN
#pod which hive entries are stored.
#pod
#pod If no hashref is provided, a new, empty hashref will be used.
#pod
#pod =cut
sub new {
my ($class, $href) = @_;
$href = {} unless defined $href;
return bless { store => $href } => $class;
}
#pod =method hash_store
#pod
#pod This method returns the hashref in which things are being used. You should not
#pod alter its contents!
#pod
#pod =cut
sub hash_store {
lib/Data/Hive/Store/Param.pm view on Meta::CPAN
my $exists = grep { $key eq $_ } $self->param_store->$method;
return ! ! $exists;
},
delete => $arg->{delete} || sub {
my ($self, $key) = @_;
$self->param_store->delete($key);
},
};
return bless $guts => $class;
}
sub param_store { $_[0]{obj} }
sub _param {
my $self = shift;
my $meth = $self->{method};
my $path = $self->name(shift);
return $self->param_store->$meth($path, @_);
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.848 second using v1.00-cache-2.02-grep-82fe00e-cpan-a086c87fca4 )