Class: Spree::Api::V2::Platform::HomepageSectionRelatableOptionsController

Inherits:
ResourceController
  • Object
show all
Defined in:
app/controllers/spree/api/v2/platform/homepage_section_relatable_options_controller.rb

Instance Method Summary collapse

Instance Method Details

#model_class ⇒ Object



6
7
8
9
10
11
12
# File 'app/controllers/spree/api/v2/platform/homepage_section_relatable_options_controller.rb', line 6

def model_class
  return Spree::Vendor if params['model_class'] == 'Spree::Vendor'
  return Spree::Product if params['model_class'] == 'Spree::Product'
  return Spree::Taxon if params['model_class'] == 'Spree::Taxon'

  nil
end

#resource_serializer ⇒ Object



14
15
16
# File 'app/controllers/spree/api/v2/platform/homepage_section_relatable_options_controller.rb', line 14

def resource_serializer
  ::SpreeCmCommissioner::Api::V2::Platform::HomepageSectionRelatableOptionsSerializer
end

#scope ⇒ Object

Opt-in only (params == 'events'/params), so existing callers that search across all taxons/vendors (e.g. ticket transfer rules, homepage sections) are unaffected.



21
22
23
24
25
26
27
# File 'app/controllers/spree/api/v2/platform/homepage_section_relatable_options_controller.rb', line 21

def scope
  result = super
  result = result.merge(Spree::Taxon.events) if model_class == Spree::Taxon && params[:taxon_scope] == 'events'
  result = scoped_to_tenant(result) if params[:tenant_id].present?

  result
end