Sha256: 91a7a061f979a708b4159457f64b07799d767a3f81bc0eaeabaafdf7d840d6f8

Contents?: true

Size: 1.39 KB

Versions: 8

Compression:

Stored size: 1.39 KB

Contents

module Locomotive
  module Liquid
    module Drops

      class AssetCollections < ::Liquid::Drop

        def before_method(meth)
          collection = @context.registers[:site].asset_collections.where(:slug => meth.to_s).first
          AssetCollectionProxy.new(collection)
        end

      end

      class AssetCollectionProxy < ::Liquid::Drop

        def initialize(collection)
          @collection = collection
        end

        def first
          @collection.ordered_assets.first
        end

        def last
          @collection.ordered_assets.last
        end

        def each(&block)
          @collection.ordered_assets.each(&block)
        end

        def paginate(options = {})
          paginated_collection = @collection.ordered_assets.paginate(options)
          {
            :collection       => paginated_collection,
            :current_page     => paginated_collection.current_page,
            :previous_page    => paginated_collection.previous_page,
            :next_page        => paginated_collection.next_page,
            :total_entries    => paginated_collection.total_entries,
            :total_pages      => paginated_collection.total_pages,
            :per_page         => paginated_collection.per_page
          }
        end

        def before_method(meth)
          return '' if @collection.nil?
          @collection.send(meth)
        end

      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
locomotive_cms-1.0.0.beta.2 lib/locomotive/liquid/drops/asset_collections.rb
locomotive_cms-1.0.0.beta lib/locomotive/liquid/drops/asset_collections.rb
locomotive_cms-0.0.4.beta12 lib/locomotive/liquid/drops/asset_collections.rb
locomotive_cms-0.0.4.beta11 lib/locomotive/liquid/drops/asset_collections.rb
locomotive_cms-0.0.4.beta10 lib/locomotive/liquid/drops/asset_collections.rb
locomotive_cms-0.0.4.beta9 lib/locomotive/liquid/drops/asset_collections.rb
locomotive_cms-0.0.4.beta8 lib/locomotive/liquid/drops/asset_collections.rb
locomotive_cms-0.0.4.beta7 lib/locomotive/liquid/drops/asset_collections.rb