MooseX::Has::Sugar::Minimal - Less Sugary Syntax for moose 'has' fields


MooseX-Has-Sugar documentation Contained in the MooseX-Has-Sugar distribution.

Index


Code Index:

NAME

Top

MooseX::Has::Sugar::Minimal - Less Sugary Syntax for moose 'has' fields

VERSION

Top

version 0.05070419

SYNOPSIS

Top

This is a legacy variant of Sugar which only exports ro and rw functions, the way MooseX::Has::Sugar used to with :is;

    use MooseX::Types::Moose qw( Str );
    use MooseX::Has::Sugar::Minimal;

    has foo => (
            isa => Str,
            is  => ro,
            required => 1,
    );
    has bar => (
            isa => Str,
            is => rw,
            lazy_build => 1,
    );

All functions are exported by The Sub::Exporter Module.

EXPORT GROUPS

Top

:default

Exports :is

:is

Exports bare, ro, rw

EXPORTED FUNCTIONS

Top

bare

returns ('bare')

ro

returns ('ro')

rw

returns ('rw')

CONFLICTS

Top

MooseX::Has::Sugar

MooseX::Has::Sugar::Saccharin

This module is not intended to be used in conjunction with::Sugar or ::Sugar::Saccharin.

We all export ro and rw in different ways.

If you do however want to use them in conjunction, specific imports must be done on MooseX::Has::Sugar's side to stop it exporting different ro/rw. Any of the below should be fine.

    use MooseX::Has::Sugar::Minimal;
    use MooseX::Has::Sugar qw( :attrs );

    has foo =>( is => rw , lazy_build );

    use MooseX::Has::Sugar::Minimal;
    use MooseX::Has::Sugar qw( lazy_build );

    has foo =>( is => rw , lazy_build );

AUTHOR

Top

Kent Fredric <kentnl at cpan.org>

COPYRIGHT AND LICENSE

Top


MooseX-Has-Sugar documentation Contained in the MooseX-Has-Sugar distribution.

use warnings;
use strict;

package MooseX::Has::Sugar::Minimal;
BEGIN {
  $MooseX::Has::Sugar::Minimal::VERSION = '0.05070419';
}

# ABSTRACT: Less Sugary Syntax for moose 'has' fields

use Sub::Exporter ();



Sub::Exporter::setup_exporter(
  {
    exports => [ 'ro', 'rw', 'bare', ],
    groups  => {
      is      => [ 'ro', 'rw', 'bare', ],
      default => ['-is'],
    }
  }
);


sub bare() {
  return ('bare');
}


sub ro() {
  return ('ro');
}


sub rw() {
  return ('rw');
}

1;


__END__