This repository was archived by the owner on Feb 23, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ def has_closure_tree(options = {})
1212 :numeric_order ,
1313 :touch ,
1414 :with_advisory_lock ,
15+ :advisory_lock_timeout_seconds ,
1516 :order_belong_to
1617 )
1718
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ def initialize(model_class, options)
2323 :dependent => :nullify , # or :destroy or :delete_all -- see the README
2424 :name_column => 'name' ,
2525 :with_advisory_lock => true ,
26+ :advisory_lock_timeout_seconds => nil ,
2627 :numeric_order => false
2728 } . merge ( options )
2829 raise ArgumentError , "name_column can't be 'path'" if options [ :name_column ] == 'path'
@@ -108,9 +109,10 @@ def where_eq(column_name, value)
108109 end
109110 end
110111
111- def with_advisory_lock ( &block )
112+ def with_advisory_lock! ( &block )
112113 if options [ :with_advisory_lock ]
113- model_class . with_advisory_lock! ( advisory_lock_name , timeout_seconds : 5 ) do
114+ lock_options = { timeout_seconds : options [ :advisory_lock_timeout_seconds ] } . compact
115+ model_class . with_advisory_lock! ( advisory_lock_name , lock_options ) do
114116 transaction { yield }
115117 end
116118 else
You can’t perform that action at this time.
0 commit comments