Sha256: 6b7ac47e5d37d127cac17c1467dd09312f55bab57bac39f31c1575a8669e2e3f

Contents?: true

Size: 979 Bytes

Versions: 9

Compression:

Stored size: 979 Bytes

Contents

# frozen_string_literal: true
module ShopifyAPI
  class Variant < Base
    include Metafields
    include DisablePrefixCheck

    conditional_prefix :product

    def initialize(*)
      super
      attributes.except!('old_inventory_quantity')
    end

    def inventory_quantity_adjustment=(new_value)
      raise_deprecated_inventory_call('inventory_quantity_adjustment')
      super
    end

    def inventory_quantity=(new_value)
      raise_deprecated_inventory_call('inventory_quantity')
      super
    end

    def old_inventory_quantity=(new_value)
      raise_deprecated_inventory_call('old_inventory_quantity')
      super
    end

    def save
      attributes.except!('inventory_quantity')
      super
    end

    private

    def raise_deprecated_inventory_call(parameter)
      raise(
        ShopifyAPI::ValidationException,
        "'#{parameter}' is deprecated - see https://help.shopify.com/en/api/guides/inventory-migration-guide",
      )
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
shopify_api-9.5.2 lib/shopify_api/resources/variant.rb
ruby_shopify_api-1.2.0 lib/ruby_shopify_api/resources/variant.rb
ruby_shopify_api-1.1.0 lib/shopify_api/resources/variant.rb
ruby_shopify_api-1.0.0 lib/shopify_api/resources/variant.rb
shopify_api-9.5.1 lib/shopify_api/resources/variant.rb
shopify_api-9.5 lib/shopify_api/resources/variant.rb
shopify_api-9.4.1 lib/shopify_api/resources/variant.rb
shopify_api-9.4.0 lib/shopify_api/resources/variant.rb
shopify_api-9.3.0 lib/shopify_api/resources/variant.rb