SHARE
TWEET

Untitled

a guest Feb 21st, 2020 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sub _generateAccessor {
  2.     CORE::state $check    = compile(ClassName, HashRef);
  3.     my ($class, $rParams) = $check->(@_);
  4.  
  5.     CORE::state $oocheck = compile_named_oo(
  6.         accessorType => Str,
  7.         accessorName => Str, { optional => 1, default => ''    },
  8.         passParams   => Any, { optional => 1, default => undef },
  9.     );
  10.     my $arg      = $oocheck->($rParams);
  11.     my $fullname =
  12.         "${class}::" . ($arg->accessorName() || $arg->accessorType());
  13.  
  14.     unless (defined &{$fullname}) {
  15.         no strict 'refs';
  16.  
  17.         my $makeAccessorFunc =
  18.             '_make_' . $arg->accessorType() . '_accessor';
  19.  
  20.         unless ($class->can($makeAccessorFunc)) {
  21.             die "Accessor generator $makeAccessorFunc not defined.";
  22.         }
  23.  
  24.         my $accessor = $class->$makeAccessorFunc($arg->passParams());
  25.  
  26.         subname($fullname, $accessor);
  27.  
  28.         *{$fullname} = $accessor;
  29.     }
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top