lib/trailblazer/activity/structures.rb in trailblazer-activity-0.4.1 vs lib/trailblazer/activity/structures.rb in trailblazer-activity-0.4.2
- old
+ new
@@ -1,28 +1,42 @@
module Trailblazer
class Activity < Module # End event is just another callable task.
+ # Builds an Activity::End instance.
+ def self.End(semantic)
+ End.new(semantic: semantic)
+ end
# Any instance of subclass of End will halt the circuit's execution when hit.
# An End event is a simple structure typically found as the last task invoked
# in an activity. The special behavior is that it
# a) maintains a semantic that is used to further connect that very event
# b) its `End#call` method returns the end instance itself as the signal.
- End = Struct.new(:semantic) do
+ class End
+ def initialize(semantic:, **options)
+ @options = options.merge(semantic: semantic)
+ end
+
def call(*args)
return self, *args
end
+
+ def to_h
+ @options
+ end
+
+ def inspect
+ to_s
+ end
+ def to_s
+ %{#<#{self.class.name} #{@options.collect{ |k,v| "#{k}=#{v.inspect}" }.join(" ")}>}
+ end
end
class Start < End
def call(*args)
return Activity::Right, *args
end
- end
-
- # Builds an Activity::End instance.
- def self.End(semantic)
- Activity::End.new(semantic)
end
class Signal; end
class Right < Signal; end
class Left < Signal; end