Skip to content

Commit 606c157

Browse files
move lock options to support_attributes so it's alongside lock name
1 parent cad9d07 commit 606c157

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/closure_tree/support.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ def where_eq(column_name, value)
114114

115115
def with_advisory_lock!(&block)
116116
if options[:with_advisory_lock]
117-
lock_options = { timeout_seconds: options[:advisory_lock_timeout_seconds] }.compact
118-
model_class.with_advisory_lock!(advisory_lock_name, lock_options) do
117+
model_class.with_advisory_lock!(advisory_lock_name, advisory_lock_options) do
119118
transaction { yield }
120119
end
121120
else

lib/closure_tree/support_attributes.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ def advisory_lock_name
88
Digest::SHA1.hexdigest("ClosureTree::#{base_class.name}")[0..32]
99
end
1010

11+
def advisory_lock_options
12+
{ timeout_seconds: options[:advisory_lock_timeout_seconds] }.compact
13+
end
14+
1115
def quoted_table_name
1216
connection.quote_table_name(table_name)
1317
end

0 commit comments

Comments
 (0)