Skip to content

Commit

Permalink
Fix Ruby "method refined" warning (#433)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mattbrictson authored Nov 5, 2024
1 parent f6b79d7 commit cfcffd1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sitemap_generator/templates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Templates
}

# Dynamically define accessors for each key defined in <tt>FILES</tt>
attr_accessor(*FILES.keys)
attr_writer(*FILES.keys)

FILES.each_key do |name|
eval(<<-ACCESSOR, binding, __FILE__ , __LINE__ + 1)
Expand Down

0 comments on commit cfcffd1

Please sign in to comment.