From 658400106addbe7059c38d00d8c5c018bf502e09 Mon Sep 17 00:00:00 2001 From: Chau Hong Linh Date: Thu, 27 Jul 2023 11:40:04 -0500 Subject: [PATCH 1/2] Fix the method Grape::Entity#exec_with_object to work with Ruby 3. --- lib/grape_entity/entity.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/grape_entity/entity.rb b/lib/grape_entity/entity.rb index 2728b9f..7489b81 100644 --- a/lib/grape_entity/entity.rb +++ b/lib/grape_entity/entity.rb @@ -514,7 +514,7 @@ def serializable_hash(runtime_options = {}) end def exec_with_object(options, &block) - if block.parameters.count == 1 + if block.parameters.count == 1 || block.parameters == [[:req], [:rest]] instance_exec(object, &block) else instance_exec(object, options, &block) @@ -523,6 +523,7 @@ def exec_with_object(options, &block) # it handles: https://github.com/ruby/ruby/blob/v3_0_0_preview1/NEWS.md#language-changes point 3, Proc # accounting for expose :foo, &:bar if e.is_a?(ArgumentError) && block.parameters == [[:req], [:rest]] + Rails.logger.error("***** ERROR in exec_with_object: #{e.message}\n#{e.backtrace.join("\n")}") raise Grape::Entity::Deprecated.new e.message, 'in ruby 3.0' end From 533b9ba969ae9d40cb20b21948a8ee9596ebf00b Mon Sep 17 00:00:00 2001 From: Chau Hong Linh Date: Thu, 27 Jul 2023 12:18:49 -0500 Subject: [PATCH 2/2] Bump the version to 1.0.1. --- lib/grape_entity/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/grape_entity/version.rb b/lib/grape_entity/version.rb index dae01ec..2f0868d 100644 --- a/lib/grape_entity/version.rb +++ b/lib/grape_entity/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module GrapeEntity - VERSION = '1.0.0' + VERSION = '1.0.1' end