lib/paraduct/variable_converter.rb in paraduct-0.0.2 vs lib/paraduct/variable_converter.rb in paraduct-0.0.3.beta2
- old
+ new
@@ -24,12 +24,19 @@
product_variables
end
def self.reject(product_variables, exclude_variables)
product_variables.inject([]) do |rejected_product_variables, variables|
- rejected_product_variables << variables unless exclude_variables.include?(variables)
+ rejected_product_variables << variables unless exclude_variables.any?{ |exclude| partial_match?(variables, exclude) }
rejected_product_variables
end
+ end
+
+ def self.partial_match?(parent_hash, child_hash)
+ child_hash.each do |k, v|
+ return false unless parent_hash[k] == v
+ end
+ true
end
def self.product_array(array)
first_values = array.shift
if array.empty?