I'm trying to figure out a way to see if one of my lazily built attributes has been set or not. I've scoured the docs for both Moose::Meta::Attribute and and Class::MOP::Attribute, and saw the get_value
and has_value
methods, but they don't seem to be working for me.
The documentation for get_value
says:
$attr->has_value($instance)
But what is $instance? I tried using my object, but that just returns the error:
"You must pass a package name and it cannot be blessed.."
Any help is appreciated!
What you probably want is a predicate on your attribute. E.g.
has foo => (
is => 'rw',
lazy => 1,
predicate => 'has_foo',
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With