File tree 2 files changed +6
-2
lines changed
elasticsearch-model/lib/elasticsearch
2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ module Model
70
70
71
71
# Keeps a registry of the classes that include `Elasticsearch::Model`
72
72
#
73
- class Registry < Array
73
+ class Registry
74
74
75
75
# Add the class of a model to the registry
76
76
#
Original file line number Diff line number Diff line change @@ -97,6 +97,10 @@ def __ids_by_type
97
97
# A simple class-level memoization over the `_index` and `_type` properties of the hit is applied.
98
98
# Hence querying the Model Registry is done the minimal amount of times.
99
99
#
100
+ # Event though memoization happens at the class level, the side effect of a race condition will only be
101
+ # to iterate over models one extra time, so we can consider the method thread-safe, and don't include
102
+ # any Mutex.synchronize around the method implementaion
103
+ #
100
104
# @see Elasticsearch::Model::Registry
101
105
#
102
106
# @return Class
@@ -106,7 +110,7 @@ def __ids_by_type
106
110
def __type ( hit )
107
111
@@__types ||= { }
108
112
@@__types [ [ hit [ :_index ] , hit [ :_type ] ] . join ( "::" ) ] ||= begin
109
- Registry . all . detect { |model | model . index_name == hit [ :_index ] && model . document_type == hit [ :_type ] }
113
+ models . detect { |model | model . index_name == hit [ :_index ] && model . document_type == hit [ :_type ] }
110
114
end
111
115
end
112
116
You can’t perform that action at this time.
0 commit comments