Skip to content

Commit 5b25ae9

Browse files
authored
Merge pull request #776 from Shopify/avoid-anonymous-eval
Avoid anonymous eval
2 parents 8773af1 + fc39edd commit 5b25ae9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/httparty/module_inheritable_attributes.rb

+3-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def mattr_inheritable(*args)
2929
@mattr_inheritable_attrs += args
3030

3131
args.each do |arg|
32-
module_eval %(class << self; attr_accessor :#{arg} end)
32+
singleton_class.attr_accessor(arg)
3333
end
3434

3535
@mattr_inheritable_attrs
@@ -42,14 +42,12 @@ def inherited(subclass)
4242
subclass.instance_variable_set(ivar, instance_variable_get(ivar).clone)
4343

4444
if instance_variable_get(ivar).respond_to?(:merge)
45-
method = <<-EOM
45+
subclass.class_eval <<~RUBY, __FILE__, __LINE__ + 1
4646
def self.#{inheritable_attribute}
4747
duplicate = ModuleInheritableAttributes.hash_deep_dup(#{ivar})
4848
#{ivar} = superclass.#{inheritable_attribute}.merge(duplicate)
4949
end
50-
EOM
51-
52-
subclass.class_eval method
50+
RUBY
5351
end
5452
end
5553
end

0 commit comments

Comments
 (0)