Class: ShopifyCLI::Theme::DevServer::HotReload::SectionsIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_cli/theme/dev_server/hot_reload/sections_index.rb

Instance Method Summary collapse

Constructor Details

#initialize(theme) ⇒ SectionsIndex

Returns a new instance of SectionsIndex.



8
9
10
# File 'lib/shopify_cli/theme/dev_server/hot_reload/sections_index.rb', line 8

def initialize(theme)
  @theme = theme
end

Instance Method Details

#section_names_by_typeObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/shopify_cli/theme/dev_server/hot_reload/sections_index.rb', line 12

def section_names_by_type
  index = {}

  files.each do |file|
    section_hash(file).each do |key, value|
      next unless key
      next unless value.is_a?(Hash)
      next unless (type = value&.dig("type"))

      index[type] = [] unless index[type]
      index[type] << key
    end
  end

  index
end