Sha256: c587093f048fc82dced52e1995c2dfe9d1ed813b9a4730d552fcce6d95e86389

Contents?: true

Size: 708 Bytes

Versions: 1

Compression:

Stored size: 708 Bytes

Contents

module CouchRest
  module Mixins
    module WillPaginate
      module ProxyMethods

        def method_missing(m, *args, &block)
          if m.to_s =~ /^paginate_(.+)/ && @klass.respond_to?(m)
            view_name = $1 # view name
            opts = args.shift || {}
            paginated_view(view_name, opts)
          else
            super
          end
        end

        def paginated_view(view_name, opts = {})
          opts = { 
            :database => @database
          }.merge(opts)
          result = @klass.paginated_view(view_name, opts)
          result.each{|doc| doc.database = @database if respond_to?(:database) } if result
          result
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
will_paginate_couchrest-0.2.2 lib/will_paginate_couchrest/proxy_methods.rb