bug: content_type should be memoized, not the ContentEntryCollection liquid drop

did committed Sep 10, 2015
commit 3e7b74b22a65527733e15e748d822995ea0ce991
Showing 1 changed file with 6 additions and 10 deletions
locomotive/steam/liquid/drops/content_types.rb b/lib/locomotive/steam/liquid/drops/content_types.rb +6 -10
@@ @@ -5,7 +5,11 @@ module Locomotive
class ContentTypes < ::Liquid::Drop
def before_method(meth)
- fetch_content_type(meth.to_s)
+ if content_type = fetch_content_type(meth.to_s)
+ ContentEntryCollection.new(content_type)
+ else
+ nil
+ end
end
private
@@ @@ -18,20 +22,12 @@ module Locomotive
@content_type_map ||= {}
if !@content_type_map.include?(slug)
- @content_type_map[slug] = _fetch_content_type(slug)
+ @content_type_map[slug] = repository.by_slug(slug)
end
@content_type_map[slug]
end
- def _fetch_content_type(slug)
- if content_type = repository.by_slug(slug)
- ContentEntryCollection.new(content_type)
- else
- nil
- end
- end
-
end
end