Remote Class Construction

class('Your::Forager::Squirrel')
    ->base('Your::Forager')
    ->throws('squirrel')
    ->messages( 
         denied => 'Tree rats are not allowed to %s.' 
      )
    ->methods( 
         forage => sub { 
             shift->error_msg( denied => 'forage' ) 
         } 
      );

Calling the Method on an Instance:

 Your::Forager::Squirrel->new->forage;

Error Thrown:

squirrel error - Tree rats are not allowed to forage
Thus Spake Andy:

If you pass a package name or object to class() then you get back a Badger::Class object for the relevant package. This example shows how we can create a new class on the fly, dynamically assigning it a base class, declaring what exception type it throws, what message formats it should use, and even attaching methods directly to it. This method simply throws an error. So we've just built a subclass which effectively disables a particular method.