Skip to content

Commit c8f7a22

Browse files
Chau Hong Linhnumbata
authored andcommitted
Fix the method Grape::Entity#exec_with_object to work with Ruby 3.
1 parent 489f9b9 commit c8f7a22

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/grape_entity/entity.rb

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

521521
def exec_with_object(options, &block)
522-
if block.parameters.count == 1
522+
if block.parameters.count == 1 || block.parameters == [[:req], [:rest]]
523523
instance_exec(object, &block)
524524
else
525525
instance_exec(object, options, &block)
@@ -528,6 +528,7 @@ def exec_with_object(options, &block)
528528
# it handles: https://github.com/ruby/ruby/blob/v3_0_0_preview1/NEWS.md#language-changes point 3, Proc
529529
# accounting for expose :foo, &:bar
530530
if e.is_a?(ArgumentError) && block.parameters == [[:req], [:rest]]
531+
Rails.logger.error("***** ERROR in exec_with_object: #{e.message}\n#{e.backtrace.join("\n")}")
531532
raise Grape::Entity::Deprecated.new e.message, 'in ruby 3.0'
532533
end
533534

0 commit comments

Comments
 (0)