Sha256: 7b2fcc810929a297f1c1f8d348e7b69039434ff99f8df1f45bec64a22b41d2b1

Contents?: true

Size: 644 Bytes

Versions: 1

Compression:

Stored size: 644 Bytes

Contents

module CouchRest
  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

Version data entries

1 entries across 1 versions & 1 rubygems

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