suppress logging when rendering each partial
This commit is contained in:
parent
0ce61dedd0
commit
e084dc4b36
2
TODO.txt
2
TODO.txt
|
@ -1,7 +1,5 @@
|
||||||
* partialize the outer div
|
* partialize the outer div
|
||||||
|
|
||||||
* suppress logging when rendering each partial
|
|
||||||
|
|
||||||
* add generator option to copy particular template
|
* add generator option to copy particular template
|
||||||
|
|
||||||
* add Haml generator
|
* add Haml generator
|
||||||
|
|
|
@ -63,10 +63,12 @@ module Kaminari
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
suppress_logging_render_partial do
|
||||||
@template.content_tag :div, :class => 'pagination' do
|
@template.content_tag :div, :class => 'pagination' do
|
||||||
tagify.join("\n").html_safe
|
tagify.join("\n").html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def tagify
|
def tagify
|
||||||
num_pages, current_page, left, window, right = @options[:num_pages], @options[:current_page], @left, @window, @right
|
num_pages, current_page, left, window, right = @options[:num_pages], @options[:current_page], @left, @window, @right
|
||||||
|
@ -96,6 +98,25 @@ module Kaminari
|
||||||
def method_missing(meth, *args, &blk)
|
def method_missing(meth, *args, &blk)
|
||||||
@template.send meth, *args, &blk
|
@template.send meth, *args, &blk
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def paginate(scope, options = {}, &block)
|
def paginate(scope, options = {}, &block)
|
||||||
|
|
Loading…
Reference in New Issue