Module: Maglev::GetPageSections::TransformCollectionItemConcern

Included in:
Maglev::GetPageSections
Defined in:
app/services/concerns/maglev/get_page_sections/transform_collection_item_concern.rb

Overview

rubocop:disable Style/ClassAndModuleChildren

Instance Method Summary collapse

Instance Method Details

#transform_collection_item_content_setting(content, setting) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/services/concerns/maglev/get_page_sections/transform_collection_item_concern.rb', line 5

def transform_collection_item_content_setting(content, setting)
  item_id = content.dig('value', 'id')
  return if item_id.blank?

  item = fetch_collection_items.call(
    collection_id: setting.options[:collection_id],
    id: item_id
  )

  content['value']['label'] = item.label
  content['value']['item'] = item.source
end