Move sorts instantiation to constructor in order

to maintain thread safety and prevent a potential race condition from
memoization.

Before this commit, freezing the search object ivar in the SortLink
class to verify that it is not being mutated was raising errors due to
this.

@ernie, @radar, let me know if this isn’t a good idea.
This commit is contained in:
Jon Atack 2014-12-14 21:22:01 +01:00
parent d41779a489
commit dd2679b6ab
1 changed files with 2 additions and 1 deletions

View File

@ -35,6 +35,7 @@ module Ransack
@context, options[:grouping] || Constants::AND
)
@scope_args = {}
@sorts ||= []
build(params.with_indifferent_access)
end
@ -83,7 +84,7 @@ module Ransack
alias :s= :sorts=
def sorts
@sorts ||= []
@sorts
end
alias :s :sorts