Skip to content

Commit 1773502

Browse files
ivoanjonobu
authored andcommitted
Avoid using Binding#receiver
This feature is only available on Ruby 2.2+ and breaks older rubies. See <https://docs.ruby-lang.org/en/2.2.0/NEWS.html> for more details.
1 parent 0784ef0 commit 1773502

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lib/ruby2_keywords.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def ruby2_keywords(name, *)
1111
end
1212
end
1313

14-
main = TOPLEVEL_BINDING.receiver
14+
main = TOPLEVEL_BINDING.eval('self')
1515
unless main.respond_to?(:ruby2_keywords, true)
1616
# call-seq:
1717
# ruby2_keywords(method_name, ...)

test/test_keyword.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_module_ruby2_keywords
2222
end
2323

2424
def test_toplevel_ruby2_keywords
25-
main = TOPLEVEL_BINDING.receiver
25+
main = TOPLEVEL_BINDING.eval('self')
2626
assert_send([main, :respond_to?, :ruby2_keywords, true])
2727
assert_operator(main.method(:ruby2_keywords).arity, :<, 0)
2828
end

0 commit comments

Comments
 (0)