From 69e55c97157b2505ab1158752f5f70c54c2ee81f Mon Sep 17 00:00:00 2001 From: JT Smith Date: Mon, 21 Mar 2011 14:40:40 -0500 Subject: [PATCH] fix --- .../DB/Result/Propositions/DemolishModule.pm | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 lib/Lacuna/DB/Result/Propositions/DemolishModule.pm diff --git a/lib/Lacuna/DB/Result/Propositions/DemolishModule.pm b/lib/Lacuna/DB/Result/Propositions/DemolishModule.pm new file mode 100644 index 00000000..070ccf05 --- /dev/null +++ b/lib/Lacuna/DB/Result/Propositions/DemolishModule.pm @@ -0,0 +1,26 @@ +package Lacuna::DB::Result::Propositions::DemolishModule; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::DB::Result::Propositions'; + +before pass => sub { + my ($self) = @_; + my $station = $self->station; + my $building = $station->buildings->find($self->scratch->{building_id}); + if (defined $building) { + $building->demolish; + } + else { + $self->pass_extra_message('Unfortunately by the time the proposition passed, the building had already been demolished, effectively nullifying the vote.'); + } +}; + +before fail => sub { + my ($self) = @_; +}; + + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); -- 2.51.2