aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2007-11-09 13:53:40 +0000
committermatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2007-11-09 13:53:40 +0000
commitce0ce002223ca83946204e78bea5c178c6808e5c (patch)
tree8844414e544218499d4b3d3eb5c633cd29ab1b1c
parent7f13f58d53cb525973474efb1bdc2721ceb5033c (diff)
downloadreaction-ce0ce002223ca83946204e78bea5c178c6808e5c.tar.gz
reaction-ce0ce002223ca83946204e78bea5c178c6808e5c.zip
replace renders with fragment
-rw-r--r--Makefile.PL1
-rw-r--r--lib/Reaction/UI/WidgetClass.pm30
2 files changed, 26 insertions, 5 deletions
diff --git a/Makefile.PL b/Makefile.PL
index aec5ca2..05fb324 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -28,6 +28,7 @@ requires 'Email::Send';
requires 'Email::MIME';
requires 'Email::MIME::Creator';
requires 'Text::CSV_XS';
+requires 'Devel::Declare' => '0.001004';
catalyst;
diff --git a/lib/Reaction/UI/WidgetClass.pm b/lib/Reaction/UI/WidgetClass.pm
index 83e3076..413b7cf 100644
--- a/lib/Reaction/UI/WidgetClass.pm
+++ b/lib/Reaction/UI/WidgetClass.pm
@@ -4,6 +4,7 @@ use Reaction::ClassExporter;
use Reaction::Class;
use Reaction::UI::Widget;
use Data::Dumper;
+use Devel::Declare;
no warnings 'once';
@@ -23,6 +24,21 @@ class WidgetClass, which {
}, # XXX zis is not ze grand design. OBSERVABLE.
string => sub (&) { -string => [ @_ ] }, # meh (maybe &;@ later?)
wrap => sub { $self->do_wrap_sub($package, @_); }, # should have class.
+ fragment => sub (@) { }, # placeholder rewritten by do_import
+ );
+ };
+
+ after do_import => sub {
+ my ($self, $pkg, $args) = @_;
+
+ Devel::Declare->install_declarator(
+ $pkg, 'fragment', DECLARE_NAME,
+ sub { },
+ sub {
+ our $FRAGMENT_CLOSURE;
+ splice(@_, 1, 1); # remove undef proto arg
+ $FRAGMENT_CLOSURE->(@_);
+ }
);
};
@@ -31,12 +47,16 @@ class WidgetClass, which {
overrides do_class_sub => sub {
my ($self, $package, $class) = @_;
# intercepts 'foo renders ...'
- local *renders::AUTOLOAD = sub {
- our $AUTOLOAD;
- shift;
- $AUTOLOAD =~ /^renders::(.*)$/;
- $self->do_renders_meth($package, $class, $1, @_);
+ our $FRAGMENT_CLOSURE;
+ local $FRAGMENT_CLOSURE = sub {
+ $self->do_renders_meth($package, $class, @_);
};
+ #local *renders::AUTOLOAD = sub {
+ # our $AUTOLOAD;
+ # shift;
+ # $AUTOLOAD =~ /^renders::(.*)$/;
+ # $self->do_renders_meth($package, $class, $1, @_);
+ #};
# intercepts 'foo over ...'
local *over::AUTOLOAD = sub {
our $AUTOLOAD;