On 26 June 2013 09:54, Faelin McCaley Landy <faelin.la...@gmail.com> wrote:

> Here's a sample of the code in question (assume the appropriate pragmas
> for type constraints):
>
>
> has 'locations' => (
>     traits  => ['Hash'],
>     is  => 'ro',
>     isa => 'HashRef[Location]',
>     handles => {
>         add_loc => 'set',
>         del_loc => 'delete',
>         get_loc => 'get',
> loc_keys => 'keys',
>  loc_vals => 'values',
>         no_locs => 'is_empty',
>         loc_count => 'count',
> loc_pairs => 'kv',
>     },
> );
>
>
> has 'regions' => (
>     traits  => ['Hash'],
>     is  => 'ro',
>     isa => 'HashRef[Region]',
>     handles => {
>         add_region => 'set',
>         del_region => 'delete',
>         get_region => 'get',
>  region_keys => 'keys',
> region_vals => 'values',
>         no_regions => 'is_empty',
>         region_count => 'count',
>  region_pairs => 'kv',
>     },
> );
>
> When I attempt to access the locations hashref or its handles from within
> this class, I only get an error saying that it could not find the requested
> hash/function. However, when I attempt to access the regions hashref/handles,
> it has no problems.
>
>
>
That code is good and dandy, but to understand whats going wrong, we'll
need the rest of the code, because its entirely likely the problem is how
you're invoking it, or the surrounding context that defines the object
you're invoking the function on.

For instance, if your code is something like

 sub foo {
    my ( $self );
    $self->locations;
 }


Then your problem is not that you're calling 'locations' wrong, but that
'$self' is undefined. And the definition of 'locations' is irrelevant to
the question.

>  When I attempt to access the locations hashref or its handles from
within this class, I only get an error saying that it could not find the
requested hash/function. However, when I attempt to access the regions
hashref/handles,
it has no problems.

^ this indicates to me that a calling-side problem is occurring, not a
class definition problem.


So please, pastebin a large chunk of code to a pastebin which replicates
your issue, which we can run locally.

-- 
Kent

Reply via email to