Class: Spree::ProductProperty

Inherits:
Base
  • Object
show all
Includes:
FilterParam, TranslatableResource
Defined in:
app/models/spree/product_property.rb

Constant Summary collapse

TRANSLATABLE_FIELDS =
%i[value filter_param].freeze

Instance Method Summary collapse

Methods inherited from Base

belongs_to_required_by_default, for_store, has_many_inversing, json_api_columns, json_api_permitted_attributes, json_api_type, page, spree_base_scopes, spree_base_uniqueness_scope

Methods included from Spree::Preferences::Preferable

#clear_preferences, #default_preferences, #defined_preferences, #deprecated_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_deprecated, #preference_type, #set_preference

Instance Method Details

#property_name=(name) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/models/spree/product_property.rb', line 35

def property_name=(name)
  Spree::Deprecation.warn(<<-DEPRECATION, caller)
    `ProductProperty#property_name=` is deprecated and will be removed in Spree 5.0.
  DEPRECATION
  if name.present?
    self.property = if Property.where(name: name).exists?
                      Property.where(name: name).first
                    else
                      Property.create(name: name, presentation: name)
                    end
  end
end