suppress logging when rendering each partial

This commit is contained in:
Akira Matsuda 2011-02-06 21:21:13 +09:00
parent 0ce61dedd0
commit e084dc4b36
2 changed files with 23 additions and 4 deletions

View File

@ -1,7 +1,5 @@
* partialize the outer div
* suppress logging when rendering each partial
* add generator option to copy particular template
* add Haml generator

View File

@ -63,8 +63,10 @@ module Kaminari
end
def to_s
@template.content_tag :div, :class => 'pagination' do
tagify.join("\n").html_safe
suppress_logging_render_partial do
@template.content_tag :div, :class => 'pagination' do
tagify.join("\n").html_safe
end
end
end
@ -96,6 +98,25 @@ module Kaminari
def method_missing(meth, *args, &blk)
@template.send meth, *args, &blk
end
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
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
end
def paginate(scope, options = {}, &block)