Skip to content

Commit

Permalink
Correct Performance/StringIdentifierArgument offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
mvz committed Dec 27, 2023
1 parent 8161245 commit b6c3310
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions lib/happymapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/happymapper/class_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/features/to_xml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/features/to_xml_with_namespaces_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b6c3310

Please sign in to comment.