diff --git a/lib/open_food_network/product_proxy.rb b/lib/open_food_network/product_proxy.rb index e7f06f0019..ecbce189a4 100644 --- a/lib/open_food_network/product_proxy.rb +++ b/lib/open_food_network/product_proxy.rb @@ -1,4 +1,7 @@ module OpenFoodNetwork + # Variants can have several fields overridden on a per-enterprise basis by the + # VariantOverride model. These overrides can be applied to variants by wrapping their + # products in this proxy, which wraps the product's variants in VariantProxy. class ProductProxy instance_methods.each { |m| undef_method m unless m =~ /(^__|^send$|^object_id$)/ } diff --git a/lib/open_food_network/variant_proxy.rb b/lib/open_food_network/variant_proxy.rb index 9764cfde06..26e6796e9a 100644 --- a/lib/open_food_network/variant_proxy.rb +++ b/lib/open_food_network/variant_proxy.rb @@ -1,4 +1,8 @@ module OpenFoodNetwork + # Variants can have several fields overridden on a per-enterprise basis by the + # VariantOverride model. These overrides can be applied to variants by wrapping in an + # instance of the VariantProxy class. This class proxies most methods back to the wrapped + # variant, but checks for overrides when fetching some properties. class VariantProxy instance_methods.each { |m| undef_method m unless m =~ /(^__|^send$|^object_id$)/ }