Skip to content

Commit 9fb8877

Browse files
committed
add_to_batch
1 parent aed6f80 commit 9fb8877

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/active_interaction/extras.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ def include_errors!(model, **mapping)
144144
end
145145
end
146146

147+
concern :AddToBatch do
148+
include ActiveInteraction::Extras::Current
149+
150+
def add_to_batch(&block)
151+
if current.batch
152+
current.batch.add(&block)
153+
else
154+
block.call
155+
end
156+
end
157+
end
158+
147159
concern :AllRunner do
148160
class AllExecution
149161
attr_reader :klass, :params

0 commit comments

Comments
 (0)