Include an example of how you define the sugar for Moose::Exporter
Shawn M Moore [Mon, 29 Sep 2008 00:41:17 +0000 (00:41 +0000)]
lib/Moose/Exporter.pm

index 74be72d..b591d3e 100644 (file)
@@ -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;