NAME
MooX::Keyword - define custom keywords in Moo.
VERSION
Version 1.01
SYNOPSIS
Quick summary of what the module does.
package Moon;
use Moo;
use MooX::Keyword {
	moon => {
		alias => 'star',
		builder => sub {
			shift->has(@_);
		}
	}
};
moon shine => (
	is => 'rw',
	default => sub { ... }
);
star light => (
	is => 'ro'
);
...
my $moon = Moon->new(
	shine => 211,
	light => [{ ... }]
);
$moon->shine(633);
$moon->light;
...
Declaring a keyword
You can declare one or more keywords on import of MooX::Keyword by providing a hash where the keys are the keyword and values are an hashref of options that must contain a builder subroutine and may contain aliases for that keyword.
package Sunset;
use MooX::Keyword {
	sunset => {
		builder => sub {
			my ($moo, $class) = @_;
			$moo->extends($class);
		}
	},
	...
};
Extending a package with keywords
You cannot use the traditional inheritance if you want to use keywords declared in another package, instead you need to pass extends when importing MooX::Keyword.
package Night 
use Moo;
use MooX::Keyword extends => ["Moon", "Sunset"];
sunset 'Day';
star polaris  => (
	is => 'ro'
);
AUTHOR
LNATION, <email at lnation.org>
BUGS
Please report any bugs or feature requests to bug-moox-keyword at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooX-Keyword. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc MooX::Keyword
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
This software is Copyright (c) 2022->2025 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)