Skip to content

experimental 'class' doesn't work with existing objects #21331

Open
@jjn1056

Description

@jjn1056

Crossposted from Perl-Apollo/Corinna#105 because its completely unclear how to start a conversation about where core class is going

So I tried to use core class with a basic Catalyst controller:

use Moose;
use MooseX::MethodAttributes;
use Example::Syntax;

class Example::Controller::Account :isa(Example::Controller) {

  sub root :At('$path_end/...') Via('../protected')  ($self, $c, $user) {
    $c->action->next($user->account);
  }

    sub prepare_edit :At('...') Via('root') ($self, $c, $account) { 
      $self->view_for('edit', account => $account);
      $c->action->next($account);
    }

      sub edit :Get('edit') Via('prepare_edit') ($self, $c, $account) {
        return  $c->view->set_http_ok;
      }

      sub update :Patch('') Via('prepare_edit') BodyModel ($self, $c, $account, $bm) {
        return $account->update_account($bm) ?
          $c->view->set_http_ok : 
            $c->view->set_http_bad_request;
      }
}

__PACKAGE__->meta->make_immutable;

But when I try to run I get a compile time error:

Class :isa attribute requires a class but "Example::Controller" is not one at lib/Example/Controller/Account.pm line 5.

I'm enabling the class pragma via the 'Example::Syntax' module , it basically does 'use experimental class'.

I would propose that code like this working should be considered mandatory before moving this out of experimental status.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions