Skip to content

Commit d9c062c

Browse files
committed
update method missing for Ruby 2.x-3.0 all at once
1 parent b4b4c6f commit d9c062c

File tree

1 file changed

+6
-3
lines changed
  • elasticsearch-model/lib/elasticsearch/model

1 file changed

+6
-3
lines changed

elasticsearch-model/lib/elasticsearch/model/proxy.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,13 @@ def initialize(target)
115115
@target = target
116116
end
117117

118-
# Delegate methods to `@target`
118+
def ruby2_keywords(*) # :nodoc:
119+
end if RUBY_VERSION < "2.7"
120+
121+
# Delegate methods to `@target`. As per [the Ruby 3.0 explanation for keyword arguments](https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/), the only way to work on Ruby <2.7, and 2.7, and 3.0+ is to use `ruby2_keywords`.
119122
#
120-
def method_missing(method_name, *args, **kwargs, &block)
121-
target.respond_to?(method_name) ? target.__send__(method_name, *args, **kwargs, &block) : super
123+
ruby2_keywords def method_missing(method_name, *arguments, &block)
124+
target.respond_to?(method_name) ? target.__send__(method_name, *arguments, &block) : super
122125
end
123126

124127
# Respond to methods from `@target`

0 commit comments

Comments
 (0)