File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ def has_closure_tree(options = {})
12
12
:numeric_order ,
13
13
:touch ,
14
14
:with_advisory_lock ,
15
+ :advisory_lock_timeout_seconds ,
15
16
:order_belong_to
16
17
)
17
18
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ def initialize(model_class, options)
23
23
:dependent => :nullify , # or :destroy or :delete_all -- see the README
24
24
:name_column => 'name' ,
25
25
:with_advisory_lock => true ,
26
+ :advisory_lock_timeout_seconds => nil ,
26
27
:numeric_order => false
27
28
} . merge ( options )
28
29
raise ArgumentError , "name_column can't be 'path'" if options [ :name_column ] == 'path'
@@ -108,9 +109,10 @@ def where_eq(column_name, value)
108
109
end
109
110
end
110
111
111
- def with_advisory_lock ( &block )
112
+ def with_advisory_lock! ( &block )
112
113
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
114
116
transaction { yield }
115
117
end
116
118
else
You can’t perform that action at this time.
0 commit comments