Ancient

 view release on metacpan or  search on metacpan

lib/util.pm  view on Meta::CPAN

Forces evaluation of a lazy value, returning the computed result.
If the value has already been forced, returns the cached result.
Non-lazy values pass through unchanged.

=head2 dig

    my $val = dig($hashref, @keys);
    my $val = dig($hashref, 'a', 'b', 'c');  # $hashref->{a}{b}{c}

Safely traverses a nested hash structure. Returns undef if any key
is missing, without throwing an exception.

=head2 tap

    my $result = tap(\&block, $value);
    my $result = tap(sub { print "Debug: $_\n" }, $value);

Executes a side-effect block with the value (setting C<$_> and passing
as argument), then returns the original value unchanged. Useful for
debugging pipelines without affecting data flow.

t/4022-object-clearer-predicate.t  view on Meta::CPAN

my $data2 = $lwc->data;
is($build_count, 2, 'Builder called again after clear');
is($data2, 'built-data', 'Rebuilt value correct');

# Test 8: Clearer on frozen object should fail
my $frozen = Person->new(name => "Frozen");
$frozen->age(40);
object::freeze($frozen);

eval { $frozen->clear_age };
ok($@, 'Clearer on frozen object throws error');
like($@, qr/frozen|Cannot modify/i, 'Error mentions frozen');

# Test 9: Predicate only (no clearer)
object::define('PredicateOnly',
    'value:Int:predicate'
);

my $po = PredicateOnly->new();
ok($po->can('has_value'), 'has_value method exists');
ok(!$po->can('clear_value'), 'clear_value method does not exist');



( run in 0.537 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )