lib/pack_material/repositories/pm_product_repo.rb
# Select the variant-defining columns with their values from a set of attributes.
# There should only ever be one variant with this set of values for a product.
# For this reason, the result includes the +pack_material_product_id+.
#
# @param sub_type_id [integer] - the MaterialResourceSubType.id
# @param attrs [hash, dry-type] - the attributes and values to filter down to a variant-defining set.
# @return [hash] just the attribute values that have to be unique for a product.
Select the variant-defining columns with their values from a set of attributes.
There should only ever be one variant with this set of values for a product.
For this reason, the result includes the +pack_material_product_id+.
Select the variant - defining columns with their values from a set of attributes . There should only ever be one variant with this set of values for a product . For this reason the result includes the + pack_material_product_id + .
def variant_defining_values(sub_type_id, attrs)
      var_code_cols = ConfigRepo.new.product_variant_code_columns(sub_type_id).map { |r| r.first.to_sym }
      var_code_cols.push(:pack_material_product_id)
      attrs.to_h.select { |a| var_code_cols.include?(a) }
    end
def variant_defining_values ( sub_type_id , attrs ) var_code_cols = ConfigRepo . new . product_variant_code_columns ( sub_type_id ) . map { | r | r . first . to_sym } var_code_cols . push ( :pack_material_product_id ) attrs . to_h . select { | a | var_code_cols . include? ( a ) } end
Select the variant-defining columns with their values from a set of attributes.
Select the variant - defining columns with their values from a set of attributes .
just the attribute values that have to be unique for a product.
just the attribute values that have to be unique for a product .
hash
sub_type_id
None
attrs
the attributes and values to filter down to a variant-defining set.
the attributes and values to filter down to a variant - defining set .