Statocles
Statocles copied to clipboard
Add data helper method on objects with data attributes
To make the templates easier to work with, it'd be nice if we had a data() method that would, if given an argument, deref the first level of reference.
my $data = $self->data; # get the raw hashref
my @ary = $self->data( 'ary' ); # deref the arrayref
my %hash = $self->data( 'hash' ); # deref the hashref
This will be most useful for arrays, as it turns
% for my $item ( @{ $self->data->{ ary } } ) {
into
% for my $item ( $self->data( 'ary' ) ) {