Sha256: 292e6f92a5382c09ad37d9fce6743446619fdd5dc7b90a9e76fa66d80efccb79

Contents?: true

Size: 730 Bytes

Versions: 8

Compression:

Stored size: 730 Bytes

Contents

module Spree
  module Api
    module V2
      class OptionValuesController < Spree::Api::V2::BaseController
        skip_before_action :authenticate_user, only: [:index, :show]

        def index
          render_collection option_values.includes(:option_type, :variants)
        end

        def show
          render_instance option_values.find(params[:id])
        end

        private

        def option_values
          if params[:option_type_id]
            Spree::OptionType.find(params[:option_type_id]).option_values
          elsif params[:variant_id]
            Spree::Variant.find(params[:variant_id]).option_values
          else
            Spree::OptionValue
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
solidus_json_api-0.3.1 app/controllers/spree/api/v2/option_values_controller.rb
solidus_json_api-0.3.0 app/controllers/spree/api/v2/option_values_controller.rb
spree_api_v2-0.2.2 app/controllers/spree/api/v2/option_values_controller.rb
solidus_api_v2-0.2.2 app/controllers/spree/api/v2/option_values_controller.rb
solidus_api_v2-0.2.1 app/controllers/spree/api/v2/option_values_controller.rb
spree_api_v2-0.2.1 app/controllers/spree/api/v2/option_values_controller.rb
spree_api_v2-0.2.0 app/controllers/spree/api/v2/option_values_controller.rb
solidus_api_v2-0.2.0 app/controllers/spree/api/v2/option_values_controller.rb