GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Sub::HandlesVia::HandlerLibrary::Scalar(3) User Contributed Perl Documentation Sub::HandlesVia::HandlerLibrary::Scalar(3)

Sub::HandlesVia::HandlerLibrary::Scalar - library of scalar-related methods

  package My::Class {
    use Moo;
    use Sub::HandlesVia;
    use Types::Standard 'Any';
    has attr => (
      is => 'rwp',
      isa => Any,
      handles_via => 'Scalar',
      handles => {
        'my_make_getter' => 'make_getter',
        'my_make_setter' => 'make_setter',
        'my_scalar_reference' => 'scalar_reference',
      },
    );
  }

This is a library of methods for Sub::HandlesVia.

Returns a getter coderef.

  my $object = My::Class->new( attr => 10 );
  my $getter = $object->my_make_getter;
  $object->_set_attr( 11 );
  say $getter->(); ## ==> 11

Returns a setter coderef.

  my $object = My::Class->new( attr => 10 );
  my $setter = $object->my_make_setter;
  $setter->( 11 );
  say $object->attr; ## ==> 11

Returns a scalar reference to the attribute value's slot within its object.

  my $object = My::Class->new( attr => 10 );
  my $ref = $object->my_scalar_reference;
  $$ref++;
  say $object->attr; ## ==> 11

Please report any bugs to <https://github.com/tobyink/p5-sub-handlesvia/issues>.

Sub::HandlesVia.

Toby Inkster <tobyink@cpan.org>.

This software is copyright (c) 2020, 2022 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

2023-04-05 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.