From ae85171b23ea3b7c4bc8a5b77aa8e20dee588360 Mon Sep 17 00:00:00 2001 From: mokus80 Date: Thu, 4 Jan 2024 14:24:18 +0100 Subject: [PATCH] remove ruby 2 support --- lib/delayed/performable_mailer.rb | 2 +- lib/delayed/performable_method.rb | 26 ++------------------------ 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/lib/delayed/performable_mailer.rb b/lib/delayed/performable_mailer.rb index 7c5d6d7b0..d1c32e7cc 100644 --- a/lib/delayed/performable_mailer.rb +++ b/lib/delayed/performable_mailer.rb @@ -3,7 +3,7 @@ module Delayed class PerformableMailer < PerformableMethod def perform - mailer = super + mailer = object.send(method_name, *args, **kwargs) mailer.respond_to?(:deliver_now) ? mailer.deliver_now : mailer.deliver end end diff --git a/lib/delayed/performable_method.rb b/lib/delayed/performable_method.rb index b8ea11dd4..99ea58dcc 100644 --- a/lib/delayed/performable_method.rb +++ b/lib/delayed/performable_method.rb @@ -23,30 +23,8 @@ def display_name end end - def kwargs - # Default to a hash so that we can handle deserializing jobs that were - # created before kwargs was available. - @kwargs || {} - end - - # In ruby 3 we need to explicitly separate regular args from the keyword-args. - if RUBY_VERSION >= '3.0' - def perform - object.send(method_name, *args, **kwargs) if object - end - else - # On ruby 2, rely on the implicit conversion from a hash to kwargs - def perform - return unless object - - arguments = args.is_a?(Array) ? args : [args] - - if kwargs.present? - object.send(method_name, *arguments, kwargs) - else - object.send(method_name, *arguments) - end - end + def perform + object.send(method_name, *args, **kwargs) if object end def method(sym)