Class: Sbmt::Outbox::BaseCreateItem
Instance Method Summary
collapse
call
Instance Method Details
#call ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/interactors/sbmt/outbox/base_create_item.rb', line 16
def call
middlewares = Middleware::Builder.new(create_item_middlewares)
middlewares.call(item_class, attributes) do
record = item_class.new(attributes)
return Failure(:missing_event_key) unless event_key
return Failure(:missing_partition_by) unless partition_by
res = item_class.config.partition_strategy
.new(partition_by, item_class.config.bucket_size)
.call
record.bucket = res.value! if res.success?
if record.save
track_last_stored_id(record.id, record.partition)
track_counter(record.partition)
Success(record)
else
Failure(record.errors)
end
end
end
|