From 05b6200c8f326a1ea5d7507f476380c359876e90 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 10 Jul 2025 14:08:36 +1000 Subject: [PATCH 1/2] Remove unused instance variable I noticed this when reviewing another pull request. --- lib/open_food_network/scope_variant_to_hub.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/open_food_network/scope_variant_to_hub.rb b/lib/open_food_network/scope_variant_to_hub.rb index 0b4e341162..e8b30abe5e 100644 --- a/lib/open_food_network/scope_variant_to_hub.rb +++ b/lib/open_food_network/scope_variant_to_hub.rb @@ -3,15 +3,13 @@ module OpenFoodNetwork class ScopeVariantToHub def initialize(hub, variant_overrides = nil) - @hub = hub - @variant_overrides = variant_overrides || VariantOverride.indexed(@hub) + @variant_overrides = variant_overrides || VariantOverride.indexed(hub) end def scope(variant) return unless OpenFoodNetwork::FeatureToggle.enabled?(:inventory, @hub) variant.extend(OpenFoodNetwork::ScopeVariantToHub::ScopeVariantToHub) - variant.instance_variable_set :@hub, @hub variant.instance_variable_set :@variant_override, @variant_overrides[variant] end From f0dd1885c93145f415be73c06badbd08291de047 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 24 Jul 2025 13:41:26 +1000 Subject: [PATCH 2/2] Fix: Check feature toggle for hub early --- lib/open_food_network/scope_variant_to_hub.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/open_food_network/scope_variant_to_hub.rb b/lib/open_food_network/scope_variant_to_hub.rb index e8b30abe5e..94427013a4 100644 --- a/lib/open_food_network/scope_variant_to_hub.rb +++ b/lib/open_food_network/scope_variant_to_hub.rb @@ -4,10 +4,11 @@ module OpenFoodNetwork class ScopeVariantToHub def initialize(hub, variant_overrides = nil) @variant_overrides = variant_overrides || VariantOverride.indexed(hub) + @inventory_enabled = OpenFoodNetwork::FeatureToggle.enabled?(:inventory, hub) end def scope(variant) - return unless OpenFoodNetwork::FeatureToggle.enabled?(:inventory, @hub) + return unless @inventory_enabled variant.extend(OpenFoodNetwork::ScopeVariantToHub::ScopeVariantToHub) variant.instance_variable_set :@variant_override, @variant_overrides[variant]