Documentation for Sub::Defer
Arthur Axel 'fREW' Schmidt [Sun, 7 Nov 2010 04:27:21 +0000 (23:27 -0500)]
lib/Sub/Defer.pm

index 816190e..c3e4089 100644 (file)
@@ -35,3 +35,44 @@ sub defer_sub {
 }
 
 1;
+
+=pod
+
+=head1 SYNOPSIS
+
+ use Sub::Defer;
+
+ my $deferred = defer_sub 'Logger::time_since_first_log' => sub {
+    my $t = time;
+    sub { time - $t };
+ };
+
+What the above does is set the Logger::time_since_first_log subroutine to be
+the codref that was passed to it, but then after it gets run once, it becomes
+the returned coderef.
+
+=head1 DESCRIPTION
+
+These subroutines provide the user with a convenient way to defer create of
+subroutines and methods until they are first called.
+
+=head1 SUBROUTINES
+
+=head2 defer_sub
+
+ my $coderef = defer_sub $name => sub { ... };
+
+RIBASUSHI FIX ME PLEASE!!!!
+
+Given name to install a subroutine into and a coderef that returns a coderef,
+this function will set up the subroutine such that when it is first called it
+will be replaced with the returned coderef.
+
+=head2 undefer_sub
+
+ my $coderef = undefer_sub \&Foo::name;
+
+If the passed coderef has been L<deferred|/defer_sub> this will "undefer" it.
+If the passed coderef has not been deferred, this will just return it.
+
+If this is confusing, take a look at the example in the L</SYNOPSIS>.