class Prestashop::Mapper::ProductOptionValue
Attributes
color[RW]
id[RW]
id_attribute_group[RW]
id_lang[RW]
name[RW]
position[RW]
Public Class Methods
cache()
click to toggle source
# File lib/prestashop/mapper/models/product_option_value.rb, line 50 def cache all display: '[id,id_attribute_group,name]' end
find_in_cache(id_attribute_group, name, id_lang)
click to toggle source
# File lib/prestashop/mapper/models/product_option_value.rb, line 46 def find_in_cache id_attribute_group, name, id_lang Client.option_values_cache.find{|v| v[:id_attribute_group] == id_attribute_group and v[:name].find_lang(name, id_lang)} if Client.option_values_cache end
new(args = {})
click to toggle source
# File lib/prestashop/mapper/models/product_option_value.rb, line 11 def initialize args = {} @id = args[:id] @id_attribute_group = args.fetch(:id_attribute_group) @color = args.fetch(:color, 0) @position = args[:position] @name = args.fetch(:name) @id_lang = args.fetch(:id_lang) end
Public Instance Methods
find_or_create()
click to toggle source
# File lib/prestashop/mapper/models/product_option_value.rb, line 28 def find_or_create result = self.class.find_in_cache id_attribute_group, name, id_lang unless result result = create Client.clear_option_values_cache end result[:id] end
hash()
click to toggle source
# File lib/prestashop/mapper/models/product_option_value.rb, line 21 def hash validate! { name: hash_lang(name, id_lang), id_attribute_group: id_attribute_group, color: color } end
validate!()
click to toggle source
Supplier
must have 1/0 as active and name must be string
# File lib/prestashop/mapper/models/product_option_value.rb, line 38 def validate! raise ArgumentError, 'id lang must be number' unless id_lang.kind_of?(Integer) raise ArgumentError, 'name must string' unless name.kind_of?(String) raise ArgumentError, 'id attribute group must be number' unless id_attribute_group.kind_of?(Integer) raise ArgumentError, 'color must be true or false' unless color == 1 or color == 0 end