Sha256: 613aac0c9f0ac4110731885e91c22862ca6d42f73f6e26c259dc9d71ca3f8ca7

Contents?: true

Size: 897 Bytes

Versions: 7

Compression:

Stored size: 897 Bytes

Contents

module Spree
  module V2
    module Storefront
      class CmsSectionSerializer < BaseSerializer
        set_type :cms_section

        attributes :name, :content, :settings, :link, :fit, :type, :position

        Spree::CmsSection::IMAGE_COUNT.each do |count|
          Spree::CmsSection::IMAGE_SIZE.each do |size|
            attribute "img_#{count}_#{size}".to_sym do |section|
              if section.send("image_#{count}").attached? && section.send("img_#{count}_#{size}").present?
                url_helpers = Rails.application.routes.url_helpers
                url_helpers.rails_representation_path(section.send("img_#{count}_#{size}"), only_path: true)
              end
            end
          end
        end

        attribute :is_fullscreen do |section|
          section.fullscreen?
        end

        belongs_to :linked_resource, polymorphic: true
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spree_api-4.3.3 app/serializers/spree/v2/storefront/cms_section_serializer.rb
spree_api-4.3.2 app/serializers/spree/v2/storefront/cms_section_serializer.rb
spree_api-4.3.1 app/serializers/spree/v2/storefront/cms_section_serializer.rb
spree_api-4.3.0 app/serializers/spree/v2/storefront/cms_section_serializer.rb
spree_api-4.3.0.rc3 app/serializers/spree/v2/storefront/cms_section_serializer.rb
spree_api-4.3.0.rc2 app/serializers/spree/v2/storefront/cms_section_serializer.rb
spree_api-4.3.0.rc1 app/serializers/spree/v2/storefront/cms_section_serializer.rb