summaryrefslogtreecommitdiffstats
path: root/t/lib/AtomicMethod.pm
diff options
context:
space:
mode:
Diffstat (limited to 't/lib/AtomicMethod.pm')
-rw-r--r--t/lib/AtomicMethod.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/t/lib/AtomicMethod.pm b/t/lib/AtomicMethod.pm
new file mode 100644
index 0000000..652159a
--- /dev/null
+++ b/t/lib/AtomicMethod.pm
@@ -0,0 +1,27 @@
+package AtomicMethod;
+use MooseX::Exporter::Easy;
+
+sub _atomic_method_meta {
+ my ($meta) = @_;
+ Moose::Meta::Class->create_anon_class(
+ superclasses => [$meta->method_metaclass],
+ roles => ['AtomicMethod::Role::Method'],
+ cache => 1,
+ )->name;
+}
+
+with_meta atomic_method => sub {
+ my ($meta, $name, $code) = @_;
+ $meta->add_method(
+ $name => _atomic_method_meta($meta)->wrap(
+ $code,
+ name => $name,
+ package_name => $meta->name,
+ associated_metaclass => $meta
+ ),
+ );
+};
+
+export;
+
+1;