Permalink
Browse files

Add Announcements::Announcement back in

    Need it for ->as_announcement. Also lines up better with Smalltalk.
  • Loading branch information...
1 parent 9d4029d commit 5375b1d0f936b7a590edad2f69d3abfc440a1e7d @sartak committed with Jun 27, 2011
Showing with 25 additions and 2 deletions.
  1. +19 −0 lib/Announcements/Announcement.pm
  2. +1 −2 lib/Announcements/SubscriptionRegistry.pm
  3. +1 −0 t/001-basic.t
  4. +1 −0 t/002-values.t
  5. +1 −0 t/003-veto.t
  6. +1 −0 t/004-vetoable.t
  7. +1 −0 t/unsubscribing.t
@@ -0,0 +1,19 @@
+package Announcements::Announcement;
+use Moose;
+
+sub as_announcement {
+ my $class = shift;
+ return $class if blessed($class);
+ return $class->new;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Announcements::Announcement - superclass for announcement classes
+
+=cut
+
@@ -38,8 +38,7 @@ sub announce {
my $announcement = shift;
my $announcer = shift;
- # autoreify an announcement class name
- $announcement = $announcement->new if !ref($announcement);
+ $announcement = $announcement->as_announcement;
for my $subscription ($self->subscriptions) {
$subscription->send($announcement, $announcer);
View
@@ -5,6 +5,7 @@ use warnings;
{
package PushedButton;
use Moose;
+ extends 'Announcements::Announcement';
package Button;
use Moose;
View
@@ -5,6 +5,7 @@ use warnings;
{
package Announcement::ChangedValue;
use Moose;
+ extends 'Announcements::Announcement';
has old_value => (
is => 'ro',
View
@@ -5,6 +5,7 @@ use warnings;
{
package Announcement::AboutToFlip;
use Moose;
+ extends 'Announcements::Announcement';
has is_vetoed => (
is => 'rw',
View
@@ -21,6 +21,7 @@ use warnings;
{
package Announcement::AboutToFlip;
use Moose;
+ extends 'Announcements::Announcement';
with 'Announcement::Vetoable';
}
View
@@ -6,6 +6,7 @@ use Announcements::Subscription;
{
package PushedButton;
use Moose;
+ extends 'Announcements::Announcement';
with 'Announcements::Announcing';
sub push {

0 comments on commit 5375b1d

Please sign in to comment.