Make Agent#dry_run! accept an optional incoming event

Akinori MUSHA %!s(int64=9) %!d(string=hace) años
padre
commit
fec382f24f
Se han modificado 1 ficheros con 7 adiciones y 2 borrados
  1. 7 2
      app/concerns/dry_runnable.rb

+ 7 - 2
app/concerns/dry_runnable.rb

@@ -1,7 +1,7 @@
1 1
 module DryRunnable
2 2
   extend ActiveSupport::Concern
3 3
 
4
-  def dry_run!
4
+  def dry_run!(event = nil)
5 5
     @dry_run = true
6 6
 
7 7
     log = StringIO.new
@@ -13,7 +13,12 @@ module DryRunnable
13 13
     begin
14 14
       raise "#{short_type} does not support dry-run" unless can_dry_run?
15 15
       readonly!
16
-      check
16
+      if event
17
+        raise "This agent cannot receive an event!" unless can_receive_events?
18
+        receive([event])
19
+      else
20
+        check
21
+      end
17 22
     rescue => e
18 23
       error "Exception during dry-run. #{e.message}: #{e.backtrace.join("\n")}"
19 24
     end