File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,12 @@ def read_collection(name, **opts)
101101 data = @underlying . read ( namespaced , **opts )
102102 return nil if data . nil?
103103 type = data . slice! ( 0 )
104- type . constantize . where ( id : data )
104+ begin
105+ type . constantize . where ( id : data )
106+ rescue NameError
107+ delete ( name )
108+ nil
109+ end
105110 end
106111
107112 ##
@@ -111,15 +116,18 @@ def read_collection(name, **opts)
111116 # @option opts [Boolean] :include_community whether to include the community ID in the cache key
112117 # @yieldreturn [ActiveRecord::Relation]
113118 def fetch_collection ( name , **opts , &block )
114- if exist? ( name , include_community : include_community ( opts ) )
115- read_collection ( name , **opts )
116- else
119+ existing = if exist? ( name , include_community : include_community ( opts ) )
120+ read_collection ( name , **opts )
121+ end
122+ if existing . nil?
117123 unless block_given?
118124 raise ArgumentError , "Can't fetch collection without a block given"
119125 end
120126 data = block . call
121127 write_collection ( name , data , **opts )
122128 data
129+ else
130+ existing
123131 end
124132 end
125133
You can’t perform that action at this time.
0 commit comments