class Prestashop::Mapper::ProductFeatureValue
Attributes
custom[RW]
id[RW]
id_feature[RW]
id_lang[RW]
value[W]
Public Class Methods
cache()
click to toggle source
# File lib/prestashop/mapper/models/product_feature_value.rb, line 54 def cache all display: '[id,id_feature,value]' end
find_in_cache(id_feature, value, id_lang)
click to toggle source
# File lib/prestashop/mapper/models/product_feature_value.rb, line 50 def find_in_cache id_feature, value, id_lang Client.feature_values_cache.find{|v| v[:id_feature] == id_feature and v[:value].find_lang(value, id_lang)} if Client.feature_values_cache end
new(args = {})
click to toggle source
# File lib/prestashop/mapper/models/product_feature_value.rb, line 12 def initialize args = {} @id = args[:id] @id_feature = args.fetch(:id_feature) @custom = args.fetch(:custom, 0) @value = args.fetch(:value) @id_lang = args.fetch(:id_lang) end
Public Instance Methods
find_or_create()
click to toggle source
# File lib/prestashop/mapper/models/product_feature_value.rb, line 33 def find_or_create result = self.class.find_in_cache id_feature, value, id_lang unless result result = create Client.clear_feature_values_cache end result[:id] end
hash()
click to toggle source
# File lib/prestashop/mapper/models/product_feature_value.rb, line 25 def hash validate! { id_feature: id_feature, custom: custom, value: hash_lang(value, id_lang) } end
validate!()
click to toggle source
# File lib/prestashop/mapper/models/product_feature_value.rb, line 42 def validate! raise ArgumentError, 'id lang must be number' unless id_lang.kind_of?(Integer) raise ArgumentError, 'id feature must string' unless id_feature.kind_of?(Integer) raise ArgumentError, 'custom must be 0 or 1' unless custom == 0 or custom == 1 raise ArgumentError, 'value must string' unless value.kind_of?(String) end
value()
click to toggle source
# File lib/prestashop/mapper/models/product_feature_value.rb, line 21 def value @value.plain end