From e195beb155f54131cd77f05c463d8f04c1a00aa1 Mon Sep 17 00:00:00 2001 From: Jell Date: Mon, 20 Nov 2023 13:35:59 +0100 Subject: [PATCH] Fix attribute translator setter This was simply not working before. --- lib/grape/router/attribute_translator.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/grape/router/attribute_translator.rb b/lib/grape/router/attribute_translator.rb index 8264e2196b..df0386bbea 100644 --- a/lib/grape/router/attribute_translator.rb +++ b/lib/grape/router/attribute_translator.rb @@ -38,15 +38,15 @@ def to_h end def method_missing(method_name, *args) - if setter?(method_name[-1]) - attributes[method_name[0..]] = *args + if setter?(method_name) + attributes[method_name.chomp("=")] = *args else attributes[method_name] end end def respond_to_missing?(method_name, _include_private = false) - if setter?(method_name[-1]) + if setter?(method_name) true else @attributes.key?(method_name) @@ -56,7 +56,7 @@ def respond_to_missing?(method_name, _include_private = false) private def setter?(method_name) - method_name[-1] == '=' + method_name.end_with?("=") end end end