Skip to content

Commit 02b72e6

Browse files
committed
Revert "moved checking whether the cached collection needs normalizing into normalize_collection"
This reverts commit 04dc1d3.
1 parent 1f5fe5f commit 02b72e6

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

lib/namespaced_env_cache.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ def read_collection(name, **opts)
9797
data = @underlying.read(namespaced, **opts)
9898
return nil if data.nil?
9999

100-
data = NamespacedEnvCache.normalize_collection(data)
100+
if data.is_a?(ActiveRecord::Relation)
101+
data = NamespacedEnvCache.normalize_collection(data)
102+
end
103+
101104
type = data.slice!(0)
102105
begin
103106
type.constantize.where(id: data)
@@ -129,14 +132,10 @@ def fetch_collection(name, **opts, &block)
129132
end
130133

131134
# Normalizes a given ActiveRecord collection for use with the cache
132-
# @param value [ActiveRecord::Relation, [String, Integer, Integer, ...]] collection to normalize
135+
# @param value [ActiveRecord::Relation] collection to normalize
133136
# @return [[String, Integer, Integer, ...]]
134137
def self.normalize_collection(value)
135-
if value.is_a?(ActiveRecord::Relation)
136-
[value[0].class.to_s, *value.map(&:id)]
137-
else
138-
value
139-
end
138+
[value[0].class.to_s, *value.map(&:id)]
140139
end
141140

142141
# We have to statically report that we support cache versioning even though this depends on the underlying class.

0 commit comments

Comments
 (0)