From 41fb49ee01364d4a2645805519ac5d40f730490b Mon Sep 17 00:00:00 2001 From: Justin Smestad Date: Tue, 5 Jun 2018 11:06:27 -0600 Subject: [PATCH] No more Object#send, using Object#public_send instead --- lib/jsonapi/consumer/helpers/dynamic_attributes.rb | 4 ++-- lib/jsonapi/consumer/query/builder.rb | 2 +- test/test_helper.rb | 4 ++-- test/unit/resource_test.rb | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/jsonapi/consumer/helpers/dynamic_attributes.rb b/lib/jsonapi/consumer/helpers/dynamic_attributes.rb index 6718100..cd8e147 100755 --- a/lib/jsonapi/consumer/helpers/dynamic_attributes.rb +++ b/lib/jsonapi/consumer/helpers/dynamic_attributes.rb @@ -11,7 +11,7 @@ def attributes=(attrs = {}) return @attributes unless attrs.present? attrs.each do |key, value| - send("#{key}=", value) + public_send("#{key}=", value) end end @@ -44,7 +44,7 @@ def method_missing(method, *args, &block) attributes[method] end end - return send(method) + return public_send(method) end normalized_method = safe_key_formatter.unformat(method.to_s) diff --git a/lib/jsonapi/consumer/query/builder.rb b/lib/jsonapi/consumer/query/builder.rb index 405b105..04f516b 100755 --- a/lib/jsonapi/consumer/query/builder.rb +++ b/lib/jsonapi/consumer/query/builder.rb @@ -102,7 +102,7 @@ def find(args = {}) end def method_missing(method_name, *args, &block) - to_a.send(method_name, *args, &block) + to_a.public_send(method_name, *args, &block) end private diff --git a/test/test_helper.rb b/test/test_helper.rb index 39546c7..26f88bb 100755 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -40,13 +40,13 @@ def with_altered_config(resource_class, changes) old_config_values = {} changes.each_pair do |key, value| old_config_values[key] = resource_class.send(key) - resource_class.send("#{key}=", value) + resource_class.public_send("#{key}=", value) end yield # restore config old_config_values.each_pair do |key, value| - resource_class.send("#{key}=", old_config_values[key]) + resource_class.public_send("#{key}=", old_config_values[key]) end end diff --git a/test/unit/resource_test.rb b/test/unit/resource_test.rb index edb4e4c..79f5b45 100755 --- a/test/unit/resource_test.rb +++ b/test/unit/resource_test.rb @@ -76,8 +76,8 @@ def test_formatted_key_accessors article = Article.new("foo-bam" => "baz") # Does not recognize dasherized attributes, fall back to hash syntax refute article.respond_to? :foo_bam - assert_equal("baz", article.send("foo-bam")) - assert_equal("baz", article.send(:"foo-bam")) + assert_equal("baz", article.public_send("foo-bam")) + assert_equal("baz", article.public_send(:"foo-bam")) assert_equal("baz", article["foo-bam"]) assert_equal("baz", article[:"foo-bam"]) end