aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/Widget/Container.pm
diff options
context:
space:
mode:
authormatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-08-13 11:43:07 +0000
committermatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-08-13 11:43:07 +0000
commitbae75beec20b3b73faa2118db8ebfa5b93c9918a (patch)
tree9a6155b95af1ca9f1fe8db75b5facda89f8a878a /lib/Reaction/UI/Widget/Container.pm
parenta3c28d596b414a9d98d9f60b69d2bb4811fbafc8 (diff)
downloadreaction-bae75beec20b3b73faa2118db8ebfa5b93c9918a.tar.gz
reaction-bae75beec20b3b73faa2118db8ebfa5b93c9918a.zip
remove class blocks from widget code
Diffstat (limited to 'lib/Reaction/UI/Widget/Container.pm')
-rw-r--r--lib/Reaction/UI/Widget/Container.pm100
1 files changed, 51 insertions, 49 deletions
diff --git a/lib/Reaction/UI/Widget/Container.pm b/lib/Reaction/UI/Widget/Container.pm
index 3b11afb..11ac72f 100644
--- a/lib/Reaction/UI/Widget/Container.pm
+++ b/lib/Reaction/UI/Widget/Container.pm
@@ -4,56 +4,58 @@ use Reaction::UI::WidgetClass;
use aliased 'Reaction::UI::ViewPort';
-class Container which {
-
- our $child_name;
-
- # somewhat evil. fragment returns ($name, $code) to pass to implements
- # or a method modifier name, so [1] will get us just the code
-
- # This is convenient to do here but DO NOT duplicate this code outside of
- # the same dist as WidgetClass since it's internals-dependent.
-
- my $child_fragment_method
- = (fragment container_child {
- arg '_' => $_{viewport}->$child_name;
- render 'viewport';
- })[1];
-
- around _method_for_fragment_name => sub {
- my $orig = shift;
- my $self = shift;
- my ($fragment_name) = @_;
- if (defined($child_name)
- && $fragment_name eq $child_name) {
- return $self->$orig(@_) || $child_fragment_method;
- }
- return $self->$orig(@_);
- };
-
- before _fragment_widget => sub {
- my ($self, $do_render, $args, $new_args) = @_;
- my @contained_names = $self->_contained_names($args->{viewport});
- foreach my $name (@contained_names) {
- $new_args->{$name} ||= sub {
- local $child_name = $name;
- $self->render($name, @_);
- };
- }
- };
-
- implements _contained_names => sub {
- my ($self, $vp) = @_;
- my @names;
- foreach my $attr ($vp->meta->compute_all_applicable_attributes) {
- next unless eval { $attr->type_constraint->name->isa(ViewPort) };
- my $name = $attr->name;
- next if ($name eq 'outer');
- push(@names, $name);
- }
- return @names;
- };
+use namespace::clean -except => [ qw(meta) ];
+
+our $child_name;
+
+# somewhat evil. fragment returns ($name, $code) to pass to implements
+# or a method modifier name, so [1] will get us just the code
+
+# This is convenient to do here but DO NOT duplicate this code outside of
+# the same dist as WidgetClass since it's internals-dependent.
+
+my $child_fragment_method
+ = (fragment container_child {
+ arg '_' => $_{viewport}->$child_name;
+ render 'viewport';
+ })[1];
+
+around _method_for_fragment_name => sub {
+ my $orig = shift;
+ my $self = shift;
+ my ($fragment_name) = @_;
+ if (defined($child_name)
+ && $fragment_name eq $child_name) {
+ return $self->$orig(@_) || $child_fragment_method;
+ }
+ return $self->$orig(@_);
};
+
+before _fragment_widget => sub {
+ my ($self, $do_render, $args, $new_args) = @_;
+ my @contained_names = $self->_contained_names($args->{viewport});
+ foreach my $name (@contained_names) {
+ $new_args->{$name} ||= sub {
+ local $child_name = $name;
+ $self->render($name, @_);
+ };
+ }
+};
+
+implements _contained_names => sub {
+ my ($self, $vp) = @_;
+ my @names;
+ foreach my $attr ($vp->meta->compute_all_applicable_attributes) {
+ next unless eval { $attr->type_constraint->name->isa(ViewPort) };
+ my $name = $attr->name;
+ next if ($name eq 'outer');
+ push(@names, $name);
+ }
+ return @names;
+};
+
+__PACKAGE__->meta->make_immutable;
+
1;