kaminari--kaminari/lib/kaminari/helpers/helpers.rb

39 lines
1.0 KiB
Ruby
Raw Normal View History

2011-02-10 18:45:43 +00:00
require File.join(File.dirname(__FILE__), 'tags')
module Kaminari
module Helpers
2011-02-16 14:24:31 +00:00
# The main class that controlls the whole process
class PaginationRenderer
def initialize(template, options) #:nodoc:
@template, @options = template, options
2011-02-16 14:24:31 +00:00
end
def to_s #:nodoc:
suppress_logging_render_partial do
Paginator.new(@template, @options).to_s
2011-02-16 14:24:31 +00:00
end
2011-02-05 14:09:07 +00:00
end
2011-02-16 14:24:31 +00:00
private
# dirty hack
def suppress_logging_render_partial(&blk)
if subscriber = ActionView::LogSubscriber.log_subscribers.detect {|ls| ls.is_a? ActionView::LogSubscriber}
class << subscriber
alias_method :render_partial_with_logging, :render_partial
# do nothing
2011-02-16 14:24:31 +00:00
def render_partial(event); end
end
ret = blk.call
class << subscriber
alias_method :render_partial, :render_partial_with_logging
undef :render_partial_with_logging
end
ret
else
blk.call
end
end
2011-02-05 14:09:07 +00:00
end
end
end