From: Shawn M Moore Date: Mon, 29 Sep 2008 00:41:17 +0000 (+0000) Subject: Include an example of how you define the sugar for Moose::Exporter X-Git-Tag: 0.59~34 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=82ad7804d09c173893d168ab9bfa5d459df8b948;p=gitmo%2FMoose.git Include an example of how you define the sugar for Moose::Exporter --- diff --git a/lib/Moose/Exporter.pm b/lib/Moose/Exporter.pm index 74be72d..b591d3e 100644 --- a/lib/Moose/Exporter.pm +++ b/lib/Moose/Exporter.pm @@ -369,11 +369,19 @@ Moose::Exporter - make an import() and unimport() just like Moose.pm use Moose::Exporter; Moose::Exporter->setup_import_methods( - with_caller => [ 'sugar1', 'sugar2' ], + with_caller => [ 'has_rw', 'sugar2' ], as_is => [ 'sugar3', \&Some::Random::thing ], also => 'Moose', ); + sub has_rw { + my ($caller, $class, $name, %options) = @_; + Class::MOP::Class->initialize($caller)->add_attribute($name, + is => 'rw', + %options, + ); + } + # then later ... package MyApp::User;