Sha256: 7c7a158d5ad92f66bbec9bab9ec85957eca27cfdc1d78a91b46e1d3fac55223e

Contents?: true

Size: 765 Bytes

Versions: 13

Compression:

Stored size: 765 Bytes

Contents

module Locomotive
  module Steam
    module Liquid
      module Drops
        class ContentTypes < ::Liquid::Drop

          def liquid_method_missing(meth)
            if content_type = fetch_content_type(meth.to_s)
              ContentEntryCollection.new(content_type)
            else
              nil
            end
          end

          private

          def repository
            @context.registers[:services].repositories.content_type
          end

          def fetch_content_type(slug)
            @content_type_map ||= {}

            if !@content_type_map.include?(slug)
              @content_type_map[slug] = repository.by_slug(slug)
            end

            @content_type_map[slug]
          end

        end

      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 lib/locomotive/steam/liquid/drops/content_types.rb
locomotivecms_steam-1.8.0.alpha1 lib/locomotive/steam/liquid/drops/content_types.rb
locomotivecms_steam-1.7.1 lib/locomotive/steam/liquid/drops/content_types.rb
locomotivecms_steam-1.7.0 lib/locomotive/steam/liquid/drops/content_types.rb
locomotivecms_steam-1.6.1 lib/locomotive/steam/liquid/drops/content_types.rb
locomotivecms_steam-1.6.0 lib/locomotive/steam/liquid/drops/content_types.rb
locomotivecms_steam-1.6.0.rc1 lib/locomotive/steam/liquid/drops/content_types.rb
locomotivecms_steam-1.6.0.beta1 lib/locomotive/steam/liquid/drops/content_types.rb
locomotivecms_steam-1.5.3 lib/locomotive/steam/liquid/drops/content_types.rb
locomotivecms_steam-1.5.2 lib/locomotive/steam/liquid/drops/content_types.rb
locomotivecms_steam-1.5.1 lib/locomotive/steam/liquid/drops/content_types.rb
locomotivecms_steam-1.5.0 lib/locomotive/steam/liquid/drops/content_types.rb
locomotivecms_steam-1.5.0.rc1 lib/locomotive/steam/liquid/drops/content_types.rb