Class: Cortex::UpdateContentItemTransaction
- Inherits:
-
ApplicationTransaction
- Object
- ApplicationTransaction
- Cortex::UpdateContentItemTransaction
- Includes:
- ContentItemable
- Defined in:
- app/transactions/cortex/update_content_item_transaction.rb
Instance Method Summary collapse
Instance Method Details
#init(input) ⇒ Object
14 15 16 |
# File 'app/transactions/cortex/update_content_item_transaction.rb', line 14 def init(input) Success(ContentItemTransactionType.new(input)) end |
#latest_history_patch(input) ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/transactions/cortex/update_content_item_transaction.rb', line 37 def latest_history_patch(input) history_patch = {} history_patch.merge! last_updated_by(input[:current_user]) input[:content_item].assign_attributes(history_patch) Success(input[:content_item]) end |
#process(input) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/transactions/cortex/update_content_item_transaction.rb', line 18 def process(input) if input.content_item content_item = input.content_item else content_item = ContentItem.find(input.id) field_items_attributes(input.content_item_params).each do |_key, field_item_attributes| content_item.field_items << UpdateFieldItemTransaction.new.call(field_item_attributes).value! end input.content_item_params.delete('field_items_attributes') content_item.assign_attributes(input.content_item_params) end Success({ content_item: content_item, current_user: input.current_user }) end |