Skip to content

Commit fc35cbc

Browse files
authored
Merge pull request #1 from linhchauatx/fix_entity_exec_with_object_to_work_with_ruby_3
Fix the method Grape::Entity#exec_with_object to work with Ruby 3.
2 parents 6267db4 + 7148f8a commit fc35cbc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/grape_entity/entity.rb

+2-1
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)