From cfcffd118e0375683aa890039976d8dc9f9949db Mon Sep 17 00:00:00 2001 From: Matt Brictson Date: Mon, 4 Nov 2024 17:18:08 -0800 Subject: [PATCH] Fix Ruby "method refined" warning (#433) When Ruby warnings are enabled, this is printed when loading the sitemap_generator gem: > sitemap_generator-6.3.0/lib/sitemap_generator/templates.rb:16):1: warning: method redefined; discarding old sitemap_sample This is because an attr reader (e.g. `sitemap_sample`) was being defined via `attr_accessor` and then immediately redefined with `define_method`. Fix by using `attr_writer` instead of `attr_accessor`, so that the attr reader is not defined twice. --- lib/sitemap_generator/templates.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sitemap_generator/templates.rb b/lib/sitemap_generator/templates.rb index 6f37235b..512c107c 100644 --- a/lib/sitemap_generator/templates.rb +++ b/lib/sitemap_generator/templates.rb @@ -13,7 +13,7 @@ class Templates } # Dynamically define accessors for each key defined in FILES - attr_accessor(*FILES.keys) + attr_writer(*FILES.keys) FILES.each_key do |name| eval(<<-ACCESSOR, binding, __FILE__ , __LINE__ + 1)