Module: Spree::V2::Storefront::TaxonSerializerDecorator

Defined in:
app/serializers/spree/v2/storefront/taxon_serializer_decorator.rb

Class Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/serializers/spree/v2/storefront/taxon_serializer_decorator.rb', line 5

def self.prepended(base)
  base.has_many :vendors, serializer: ::Spree::V2::Storefront::VendorSerializer
  base.has_many :visible_products, serializer: ::Spree::V2::Storefront::ProductSerializer

  base.has_one :category_icon, serializer: ::SpreeCmCommissioner::V2::Storefront::AssetSerializer
  base.has_one :app_banner, serializer: ::SpreeCmCommissioner::V2::Storefront::AssetSerializer
  base.has_one :web_banner, serializer: ::SpreeCmCommissioner::V2::Storefront::AssetSerializer
  base.has_one :home_banner, serializer: ::SpreeCmCommissioner::V2::Storefront::AssetSerializer

  base.attributes :custom_redirect_url, :kind, :subtitle, :from_date, :to_date,
                  :background_color, :foreground_color, :show_badge_status,
                  :purchasable_on, :vendor_id

  base.attribute :purchasable_on_app do |taxon|
    taxon.purchasable_on == 'app' || taxon.purchasable_on == 'both'
  end

  base.attribute :purchasable_on_web do |taxon|
    taxon.purchasable_on == 'web' || taxon.purchasable_on == 'both'
  end
end