Class: ThemeObjectsSettingMetadataSerializer

Inherits:
ApplicationSerializer show all
Defined in:
app/serializers/theme_objects_setting_metadata_serializer.rb

Instance Method Summary collapse

Methods inherited from ApplicationSerializer

expire_cache_fragment!, fragment_cache

Methods inherited from ActiveModel::Serializer

#include!

Instance Method Details

#categoriesObject



6
7
8
9
10
11
12
13
# File 'app/serializers/theme_objects_setting_metadata_serializer.rb', line 6

def categories
  object
    .categories(scope)
    .reduce({}) do |acc, category|
      acc[category.id] = BasicCategorySerializer.new(category, scope: scope, root: false).as_json
      acc
    end
end

#property_descriptionsObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/serializers/theme_objects_setting_metadata_serializer.rb', line 15

def property_descriptions
  locales = {}
  key = "theme_metadata.settings.#{object.name}.schema.properties."

  object.theme.internal_translations.each do |internal_translation|
    if internal_translation.key.start_with?(key)
      locales[internal_translation.key.delete_prefix(key)] = internal_translation.value
    end
  end

  locales
end