Skip to content

Commit 41fb49e

Browse files
committed
No more Object#send, using Object#public_send instead
1 parent 1312c03 commit 41fb49e

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

lib/jsonapi/consumer/helpers/dynamic_attributes.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def attributes=(attrs = {})
1111

1212
return @attributes unless attrs.present?
1313
attrs.each do |key, value|
14-
send("#{key}=", value)
14+
public_send("#{key}=", value)
1515
end
1616
end
1717

@@ -44,7 +44,7 @@ def method_missing(method, *args, &block)
4444
attributes[method]
4545
end
4646
end
47-
return send(method)
47+
return public_send(method)
4848
end
4949

5050
normalized_method = safe_key_formatter.unformat(method.to_s)

lib/jsonapi/consumer/query/builder.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def find(args = {})
102102
end
103103

104104
def method_missing(method_name, *args, &block)
105-
to_a.send(method_name, *args, &block)
105+
to_a.public_send(method_name, *args, &block)
106106
end
107107

108108
private

test/test_helper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ def with_altered_config(resource_class, changes)
4040
old_config_values = {}
4141
changes.each_pair do |key, value|
4242
old_config_values[key] = resource_class.send(key)
43-
resource_class.send("#{key}=", value)
43+
resource_class.public_send("#{key}=", value)
4444
end
4545

4646
yield
4747

4848
# restore config
4949
old_config_values.each_pair do |key, value|
50-
resource_class.send("#{key}=", old_config_values[key])
50+
resource_class.public_send("#{key}=", old_config_values[key])
5151
end
5252
end

test/unit/resource_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def test_formatted_key_accessors
7676
article = Article.new("foo-bam" => "baz")
7777
# Does not recognize dasherized attributes, fall back to hash syntax
7878
refute article.respond_to? :foo_bam
79-
assert_equal("baz", article.send("foo-bam"))
80-
assert_equal("baz", article.send(:"foo-bam"))
79+
assert_equal("baz", article.public_send("foo-bam"))
80+
assert_equal("baz", article.public_send(:"foo-bam"))
8181
assert_equal("baz", article["foo-bam"])
8282
assert_equal("baz", article[:"foo-bam"])
8383
end

0 commit comments

Comments
 (0)