Sha256: 0464fd3d291ba9de42012720425f318de485a790ef16ac4ea82002c26b19e6ba

Contents?: true

Size: 760 Bytes

Versions: 3

Compression:

Stored size: 760 Bytes

Contents

require 'will_paginate/view_helpers/base'
require 'will_paginate/view_helpers/link_renderer'

module WillPaginate::ViewHelpers
  class LinkRenderer
    def url( page )
      "#{@options[:params][:url]}/#{page}"
    end
  end
end


module CollectionHelper

 helpers do
   include WillPaginate::ViewHelpers::Base   
   
   # format indexes to key:orientation
   def format_index( pair )
     buff = []
     buff << pair.first
     buff << orientation( pair.last )
     buff.join( ":" )
  end
  
  # converts orientation to human
  def orientation( value )
    return "id" if value.is_a?(Mongo::ObjectID)
    case( value.to_i )
      when Mongo::ASCENDING  : "asc"
      when Mongo::DESCENDING : "desc"
      else                     "n/a"
    end
  end

 end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongo3-0.0.7 lib/helpers/collection_helper.rb
mongo3-0.0.6 lib/helpers/collection_helper.rb
mongo3-0.0.5 lib/helpers/collection_helper.rb