Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/redis_mutex/macro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def method_added(target)
raise ArgumentError, "You are trying to lock on unknown arguments: #{unknown_arguments.join(', ')}"
end

define_method(with_method) do |*args|
define_method(with_method) do |*args, **kwargs|
named_arguments = Hash[target_argument_names.zip(args)]
arguments = mutex_arguments.map { |name| named_arguments.fetch(name) }
arguments = mutex_arguments.map { |name| named_arguments.fetch(name) } + kwargs.values
key = format(
"%<class>s#%<target>s:%<arguments>s",
class: self.class.name,
Expand All @@ -46,10 +46,10 @@ def method_added(target)
)
begin
RedisMutex.with_lock(key, options) do
send(without_method, *args)
send(without_method, *args, **kwargs)
end
rescue RedisMutex::LockError
send(after_method, *args) if respond_to?(after_method)
send(after_method, *args, **kwargs) if respond_to?(after_method)
end
end

Expand Down