Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use triggers to ensure that Column object is synced with Accelerator …

…and Photocathode objects (which internally reference each other)
  • Loading branch information...
commit e9db34dcd6d8f34eefcc5be8eba1f90e1434f4d0 1 parent 100c35d
@jberger authored
Showing with 15 additions and 15 deletions.
  1. +15 −15 lib/Physics/UEMColumn/Column.pm
View
30 lib/Physics/UEMColumn/Column.pm
@@ -48,19 +48,19 @@ has accelerator => (
isa => 'Physics::UEMColumn::Accelerator',
is => 'ro',
predicate => 'has_accelerator',
-# trigger => \&_trigger_accelerator,
+ trigger => \&_trigger_accelerator,
);
-#method _trigger_accelerator ($acc, $old_acc?) {
-# my $elements = $self->elements;
+method _trigger_accelerator ($acc, $old_acc?) {
+ my $elements = $self->elements;
-# if (eval{ $elements->[0]->isa('Physics::UEMColumn::Accelerator') }) {
-# shift @$elements;
-# }
+ if (eval{ $elements->[0]->isa('Physics::UEMColumn::Accelerator') }) {
+ shift @$elements;
+ }
-# unshift @$elements, $acc;
+ unshift @$elements, $acc;
-#}
+}
=item C<photocathode>
@@ -72,7 +72,7 @@ has photocathode => (
isa => 'Physics::UEMColumn::Photocathode',
is => 'ro',
predicate => 'has_photocathode',
-# trigger => sub { $_[1]->column( $_[0] ) },
+ trigger => sub { $_[1]->column( $_[0] ) },
);
=item C<elements>
@@ -99,12 +99,12 @@ The length of the column. This value is required. This value defines then end of
has 'length' => ( isa => num_of_unit('m'), is => 'rw', required => 1 );
-method BUILD (Item $params) {
- if ($self->has_accelerator && $self->has_photocathode) {
- $self->add_element( $self->accelerator );
- $self->photocathode->column( $self );
- }
-}
+#method BUILD (Item $params) {
+# if ($self->has_accelerator && $self->has_photocathode) {
+# $self->add_element( $self->accelerator );
+# $self->photocathode->column( $self );
+# }
+#}
=back
Please sign in to comment.
Something went wrong with that request. Please try again.