Skip to content

Commit 7148f8a

Browse files
author
Chau Hong Linh
committed
Fix the method Grape::Entity#exec_with_object to work with Ruby 3.
1 parent 6267db4 commit 7148f8a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/grape_entity/entity.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ def serializable_hash(runtime_options = {})
514514
end
515515

516516
def exec_with_object(options, &block)
517-
if block.parameters.count == 1
517+
if block.parameters.count == 1 || block.parameters == [[:req], [:rest]]
518518
instance_exec(object, &block)
519519
else
520520
instance_exec(object, options, &block)
@@ -523,6 +523,7 @@ def exec_with_object(options, &block)
523523
# it handles: https://github.com/ruby/ruby/blob/v3_0_0_preview1/NEWS.md#language-changes point 3, Proc
524524
# accounting for expose :foo, &:bar
525525
if e.is_a?(ArgumentError) && block.parameters == [[:req], [:rest]]
526+
Rails.logger.error("***** ERROR in exec_with_object: #{e.message}\n#{e.backtrace.join("\n")}")
526527
raise Grape::Entity::Deprecated.new e.message, 'in ruby 3.0'
527528
end
528529

0 commit comments

Comments
 (0)