Sha256: 3c5b468173f472fc6694d06b3b05aa70f387cf551a431d5696e1da143680d6a4

Contents?: true

Size: 1.23 KB

Versions: 16

Compression:

Stored size: 1.23 KB

Contents

module Spree
  module V2
    module Storefront
      class TaxonSerializer < BaseSerializer
        set_type   :taxon

        attributes :name, :pretty_name, :permalink, :seo_title, :description, :meta_title, :meta_description,
                   :meta_keywords, :left, :right, :position, :depth, :updated_at, :public_metadata

        attribute :is_root do |taxon|
          taxon.root?
        end

        attribute :is_child do |taxon|
          taxon.child?
        end

        attribute :is_leaf do |taxon|
          taxon.leaf?
        end

        attribute :localized_slugs do |taxon, params|
          taxon.localized_slugs_for_store(params[:store])
        end

        belongs_to :parent,   record_type: :taxon, serializer: :taxon
        belongs_to :taxonomy, record_type: :taxonomy

        has_many   :children, record_type: :taxon, serializer: :taxon
        has_many   :products, record_type: :product,
                              if: proc { |_taxon, params| params && params[:include_products] == true }

        has_one    :image,
                   object_method_name: :icon,
                   id_method_name: :icon_id,
                   record_type: :taxon_image,
                   serializer: :taxon_image
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
spree_api-4.10.1 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.10.0 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.9.0 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.8.3 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.8.2 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.7.3 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.6.6 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.6.5 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.7.2 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.7.1 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.6.4 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.7.0 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.6.3 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.6.2 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.6.1 app/serializers/spree/v2/storefront/taxon_serializer.rb
spree_api-4.6.0 app/serializers/spree/v2/storefront/taxon_serializer.rb