Skip to content

Commit

Permalink
check key class before call Rails.cache.delete
Browse files Browse the repository at this point in the history
  • Loading branch information
abdellani committed Oct 26, 2023
1 parent 5360df6 commit 22e878a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/controllers/spree/admin/payment_methods_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,16 @@ def update_params

def clear_preference_cache
@payment_method.calculator.preferences.each_key do |key|
Rails.cache.delete(@payment_method.calculator.preference_cache_key(key))
delete_from_cache @payment_method.calculator.preference_cache_key(key)
end
end

def delete_from_cache(cache_key)
return unless cache_key.class in [String, Integer, Float, Symbol]

Rails.cache.delete(cache_key)
end

def add_type_to_calculator_attributes(hash)
hash["calculator_attributes"]["type"] = hash["calculator_type"]
end
Expand Down

0 comments on commit 22e878a

Please sign in to comment.