Module: Kitchen::Directions::BakeAllChapterSolutionsTypes

Defined in:
lib/kitchen/directions/bake_all_chapter_solutions_types.rb

Class Method Summary collapse

Class Method Details

.v1(chapter:, within:, metadata_source:, uuid_prefix: '') ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/kitchen/directions/bake_all_chapter_solutions_types.rb', line 6

def self.v1(chapter:, within:, metadata_source:, uuid_prefix: '')
  solutions_clipboard = Kitchen::Clipboard.new

  within.search_with(ExerciseElementEnumerator, InjectedQuestionElementEnumerator)\
        .each do |exercise|

    solution = exercise.solution
    next unless solution.present?

    solution.cut(to: solutions_clipboard)
  end

  content = solutions_clipboard.paste

  Kitchen::Directions::CompositePageContainer.v1(
    container_key: 'solutions',
    uuid_key: "#{uuid_prefix}solutions",
    metadata_source: ,
    content: content,
    append_to: chapter
  )
end