Sha256: 202a4c72fcdc2be7e6a8c7b6341c42888e0fda1707dc854e50e01a33c70e7ef1

Contents?: true

Size: 811 Bytes

Versions: 29

Compression:

Stored size: 811 Bytes

Contents

module WillPaginate::Liquidized
  def self.included(base)
    WillPaginate::Collection.class_eval do 
      def to_liquid
        WillPaginate::CollectionDrop.new self    
      end

      def collect(&block)    
        dup.replace super.collect(&block)
      end
    end  
  end
  
  class CollectionDrop < Liquid::Drop
    attr_reader :source
  
    def initialize(source)
      @source = source
    end
    
    def [](*args)
      return @source[*args]
    end
    
    def method_missing(method, &block)
     allow = [:current_page, :per_page, :total_entries, :offset, :total_pages, 
              :previous_page, :next_page, :empty?, :length, :sort_by]
     unless allow.include? method
       super.method_missing method, &block
     else
        @source.send method, &block
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
liquid_cms-0.3.2.0 lib/generators/liquid_cms/templates/vendor/plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.2.2.0 generators/liquid_cms/templates/vendor/plugins/cms_plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.2.1.1 generators/liquid_cms/templates/vendor/plugins/cms_plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.3.1.0 lib/generators/liquid_cms/templates/vendor/plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.2.1.0 generators/liquid_cms/templates/vendor/plugins/cms_plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.2.0.13 generators/liquid_cms/templates/vendor/plugins/cms_plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.3.0.10 lib/generators/liquid_cms/templates/vendor/plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.3.0.9 lib/generators/liquid_cms/templates/vendor/plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.2.0.12 generators/liquid_cms/templates/vendor/plugins/cms_plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.2.0.11 generators/liquid_cms/templates/vendor/plugins/cms_plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.2.0.10 generators/liquid_cms/templates/vendor/plugins/cms_plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.3.0.8 lib/generators/liquid_cms/templates/vendor/plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.2.0.9 generators/liquid_cms/templates/vendor/plugins/cms_plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.3.0.7 lib/generators/liquid_cms/templates/vendor/plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.3.0.6 lib/generators/liquid_cms/templates/vendor/plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.2.0.8 generators/liquid_cms/templates/vendor/plugins/cms_plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.3.0.5 lib/generators/liquid_cms/templates/vendor/plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.2.0.7 generators/liquid_cms/templates/vendor/plugins/cms_plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.3.0.4 lib/generators/liquid_cms/templates/vendor/plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb
liquid_cms-0.2.0.6 generators/liquid_cms/templates/vendor/plugins/cms_plugins/will_paginate-liquidized/lib/will_paginate/liquidized.rb