Skip to content
Snippets Groups Projects
Commit 1c381596 authored by pjs's avatar pjs
Browse files

Handle varargs w/o deprecation warnings in 2.7+

parent b72ce230
No related branches found
No related tags found
No related merge requests found
......@@ -54,7 +54,7 @@ module SimpleKit
# - +args+ -> zero or more named arguments to pass to the event
# at invocation time. These should be specified with labels, and
# consequently they can be placed in any order.
def schedule(event, delay, **args)
def schedule(event, delay, args = {})
raise 'Model scheduled event with negative delay.' if delay < 0
@event_list.push EventNotice.new(event, @model_time, delay, args)
end
......@@ -65,9 +65,10 @@ module SimpleKit
# all be a match with the corresponding +args+ of the scheduled event
# in order for the cancellation to apply, but +args+ which are not
# specified do not affect the target event matching.
def cancel(event, **args)
def cancel(event, args = {})
@cancel_set[event] ||= Set.new
@cancel_set[event].add(args.empty? ? nil : args)
# @cancel_set[event].add(args.empty? ? nil : args)
@cancel_set[event].add(args)
end
# Cancel all currently scheduled events of type +event+.
......@@ -96,7 +97,7 @@ module SimpleKit
if current_event.args.empty?
@user_model.send(current_event.event)
else
@user_model.send(current_event.event, current_event.args)
@user_model.send(current_event.event, **current_event.args)
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment