Skip to content

Commit

Permalink
remove ruby 2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
mokus80 committed Jan 4, 2024
1 parent 918ab1a commit ae85171
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lib/delayed/performable_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 2 additions & 24 deletions lib/delayed/performable_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ae85171

Please sign in to comment.