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


Manual Reference Pages  -  MOOX::HANDLESVIA (3)

.ds Aq ’

NAME

MooX::HandlesVia - NativeTrait-like behavior for Moo.

CONTENTS

VERSION

version 0.001008

SYNOPSIS



  {
    package Hashy;
    use Moo;
    use MooX::HandlesVia;

    has hash => (
      is => rw,
      handles_via => Hash,
      handles => {
        get_val => get,
        set_val => set,
        all_keys => keys
      }
    );
  }

  my $h = Hashy->new(hash => { a => 1, b => 2});

  $h->get_val(b); # 2

  $h->set_val(a, BAR); # sets a to BAR

  my @keys = $h->all_keys; # returns a, b



DESCRIPTION

MooX::HandlesVia is an extension of Moo’s ’handles’ attribute functionality. It provides a means of proxying functionality from an external class to the given atttribute. This is most commonly used as a way to emulate ’Native Trait’ behavior that has become commonplace in Moose code, for which there was no Moo alternative.

SHORTCOMINGS

Due to current Moo implementation details there are some deficiencies in how MooX::HandlesVia in comparison to what you would expect from Moose native traits.
o methods delegated via the Moo ’handles’ interface are passed the attribue value directly. and there is no way to access the parent class. This means if an attribute is updated any triggers or type coercions <B>WILL NOTB> fire.
o Moo attribute method delegations are passed the attribute value. This is fine for references (objects, arrays, hashrefs..) it means simple scalar types are <B>READ ONLYB>. This unfortunately means Number, String, Counter, Bool cannot modify the attributes value, rendering them largely useless.

PROVIDED INTERFACE/FUNCTIONS

<B>process_has(@_)B> MooX::HandlesVia preprocesses arguments passed to has() attribute declarations via the process_has function. In a given Moo class, If ’handles_via’ is set to a ClassName string, and ’handles’ is set with a hashref mapping of desired moo class methods that should map to ClassName methods, process_has() will create the appropriate binding to create the mapping IF ClassName provides that named method.



  has options => (
    is => rw,
    handles_via => Array,
    handles => {
      mixup => shuffle,
      unique_options => uniq,
      all_options => elements
    }
  );



The following handles_via keywords are reserved as shorthand for mapping to Data::Perl:
o <B>HashB> maps to Data::Perl::Collection::Hash::MooseLike
o <B>ArrayB> maps to Data::Perl::Collection::Array::MooseLike
o <B>StringB> maps to Data::Perl::String::MooseLike
o <B>NumberB> maps to Data::Perl::Number::MooseLike
o <B>BoolB> maps to Data::Perl::Bool::MooseLike
o <B>CodeB> maps to Data::Perl::Code

SEE ALSO

o Moo
o MooX::late

AUTHOR

Matthew Phillips <mattp@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Matthew Phillips <mattp@cpan.org>.

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

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


perl v5.20.3 MOOX::HANDLESVIA (3) 2015-03-31

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