From b6c3310ed55122443141c1bed5919a4046e2e26a Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Wed, 27 Dec 2023 11:29:16 +0100 Subject: [PATCH] Correct Performance/StringIdentifierArgument offenses --- lib/happymapper.rb | 8 ++++---- lib/happymapper/class_methods.rb | 6 +++--- spec/features/to_xml_spec.rb | 4 ++-- spec/features/to_xml_with_namespaces_spec.rb | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/happymapper.rb b/lib/happymapper.rb index f6bbd9e..b72ec63 100644 --- a/lib/happymapper.rb +++ b/lib/happymapper.rb @@ -44,7 +44,7 @@ def self.included(base) def initialize super self.class.attributes.reject { |attr| attr.default.nil? }.each do |attr| - send("#{attr.method_name}=", attr.default) + send(:"#{attr.method_name}=", attr.default) end end @@ -103,7 +103,7 @@ def to_xml(builder = nil, default_namespace = nil, namespace_override = nil, # tag_name = tag_from_parent || self.class.tag_name - builder.send("#{tag_name}_", attributes) do |xml| + builder.send(:"#{tag_name}_", attributes) do |xml| register_namespaces_with_builder(builder) xml.parent.namespace = @@ -287,9 +287,9 @@ def element_to_xml(element, xml, default_namespace) # we should append the value for the tag # if item_namespace - xml[item_namespace].send("#{tag}_", item.to_s) + xml[item_namespace].send(:"#{tag}_", item.to_s) else - xml.send("#{tag}_", item.to_s) + xml.send(:"#{tag}_", item.to_s) end end end diff --git a/lib/happymapper/class_methods.rb b/lib/happymapper/class_methods.rb index 3499723..7ca84cc 100644 --- a/lib/happymapper/class_methods.rb +++ b/lib/happymapper/class_methods.rb @@ -425,15 +425,15 @@ def parse_node(node, options, namespace, namespaces) attributes.each do |attr| value = attr.from_xml_node(node, namespace, namespaces) value = attr.default if value.nil? - obj.send("#{attr.method_name}=", value) + obj.send(:"#{attr.method_name}=", value) end elements.each do |elem| - obj.send("#{elem.method_name}=", elem.from_xml_node(node, namespace, namespaces)) + obj.send(:"#{elem.method_name}=", elem.from_xml_node(node, namespace, namespaces)) end if (content = defined_content) - obj.send("#{content.method_name}=", + obj.send(:"#{content.method_name}=", content.from_xml_node(node, namespace, namespaces)) end diff --git a/spec/features/to_xml_spec.rb b/spec/features/to_xml_spec.rb index 49eeb01..3455e3b 100644 --- a/spec/features/to_xml_spec.rb +++ b/spec/features/to_xml_spec.rb @@ -61,7 +61,7 @@ def when_saving_location(loc) def initialize(parameters) parameters.each_pair do |property, value| - send("#{property}=", value) if respond_to?("#{property}=") + send(:"#{property}=", value) if respond_to?(:"#{property}=") end @modified = @temporary = true end @@ -97,7 +97,7 @@ def initialize(desc, cat) def initialize(parameters) parameters.each_pair do |property, value| - send("#{property}=", value) if respond_to?("#{property}=") + send(:"#{property}=", value) if respond_to?(:"#{property}=") end end end diff --git a/spec/features/to_xml_with_namespaces_spec.rb b/spec/features/to_xml_with_namespaces_spec.rb index cb00a59..b62c35e 100644 --- a/spec/features/to_xml_with_namespaces_spec.rb +++ b/spec/features/to_xml_with_namespaces_spec.rb @@ -63,7 +63,7 @@ def when_saving_location(loc) def initialize(parameters) parameters.each_pair do |property, value| - send("#{property}=", value) if respond_to?("#{property}=") + send(:"#{property}=", value) if respond_to?(:"#{property}=") end end end @@ -84,7 +84,7 @@ class Country def initialize(parameters) parameters.each_pair do |property, value| - send("#{property}=", value) if respond_to?("#{property}=") + send(:"#{property}=", value) if respond_to?(:"#{property}=") end end end @@ -107,7 +107,7 @@ class Recipe def initialize(parameters) parameters.each_pair do |property, value| - send("#{property}=", value) if respond_to?("#{property}=") + send(:"#{property}=", value) if respond_to?(:"#{property}=") end end end