Skip to content

Commit

Permalink
suppress logging when rendering each partial
Browse files Browse the repository at this point in the history
  • Loading branch information
amatsuda committed Feb 6, 2011
1 parent 0ce61de commit e084dc4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
2 changes: 0 additions & 2 deletions TODO.txt
@@ -1,7 +1,5 @@
* partialize the outer div

* suppress logging when rendering each partial

* add generator option to copy particular template

* add Haml generator
Expand Down
25 changes: 23 additions & 2 deletions lib/kaminari/helpers.rb
Expand Up @@ -63,8 +63,10 @@ def initialize(template, options)
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

Expand Down Expand Up @@ -96,6 +98,25 @@ def tagify
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)
Expand Down

0 comments on commit e084dc4

Please sign in to comment.