Sha256: 0ea2316f6e0414ea8aa561e7f7279785e1ef5e761b533f09d4e75b19c63ad907

Contents?: true

Size: 975 Bytes

Versions: 3

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literal: true

# rubocop:disable Metrics/ParameterLists
# More parameters are ok here because these generic classes DRY up a lot of other code
module Kitchen::Directions::MoveCustomSectionToEocContainer
  class V1
    def bake(chapter:, metadata_source:, container_key:, uuid_key:,
             section_selector:, append_to:, include_intro_page:, &block)
      section_clipboard = Kitchen::Clipboard.new
      pages = include_intro_page ? chapter.pages : chapter.non_introduction_pages
      sections = pages.search(section_selector)
      sections.each(&block)
      sections.cut(to: section_clipboard)

      return if section_clipboard.none?

      Kitchen::Directions::EocCompositePageContainer.v1(
        container_key: container_key,
        uuid_key: uuid_key,
        metadata_source: metadata_source,
        content: section_clipboard.paste,
        append_to: append_to || chapter
      )
    end
  end
end
# rubocop:enable Metrics/ParameterLists

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
openstax_kitchen-9.2.0 lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb
openstax_kitchen-9.1.0 lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb
openstax_kitchen-9.0.0 lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb