From f7da4e1d99ea716f5fb189c810899894b6069c64 Mon Sep 17 00:00:00 2001 From: Colin Surprenant Date: Wed, 8 May 2013 16:55:05 -0400 Subject: [PATCH] issue #56 - make topology class configure statement optional --- lib/red_storm/simple_topology.rb | 8 +++++++- spec/red_storm/simple_topology_spec.rb | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/red_storm/simple_topology.rb b/lib/red_storm/simple_topology.rb index 880365d..5a8e82d 100644 --- a/lib/red_storm/simple_topology.rb +++ b/lib/red_storm/simple_topology.rb @@ -127,8 +127,14 @@ module RedStorm self.components << bolt end + # hook into the class lifecycle "inherited" method to automatically set the + # topology class into the Configuration object. + # this now makes the topology configure block optional. + def self.inherited(subclass) + Configuration.topology_class = subclass + end + def self.configure(name = nil, &configure_block) - Configuration.topology_class = self @topology_name = name if name @configure_block = configure_block if block_given? end diff --git a/spec/red_storm/simple_topology_spec.rb b/spec/red_storm/simple_topology_spec.rb index 53b2de4..0cea5a4 100644 --- a/spec/red_storm/simple_topology_spec.rb +++ b/spec/red_storm/simple_topology_spec.rb @@ -32,6 +32,10 @@ describe RedStorm::SimpleTopology do Topology1.topology_name.should == "topology1" end + it "should set topology class in Configuration object" do + class UnconfiguredTopology < RedStorm::SimpleTopology; end + RedStorm::Configuration.topology_class.name.should == "UnconfiguredTopology" + end describe "interface" do it "should implement topology proxy" do