mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
refs #91 avoid "super called outside of method" error on particular versions of Ruby 1.8.7
actually this seems like a Ruby's bug, but anyway I should better not use super inside a block http://www.datatravels.com/technotes/2010/02/24/ruby-187-patchlevel-inconsistency-super-called-out/ http://redmine.ruby-lang.org/issues/show/2537
This commit is contained in:
parent
cf8a49b0c3
commit
36d07200c9
1 changed files with 15 additions and 21 deletions
|
@ -47,29 +47,23 @@ module Kaminari
|
|||
end
|
||||
|
||||
def to_s #:nodoc:
|
||||
suppress_logging_render_partial do
|
||||
super @window_options.merge(@options).merge :paginator => self
|
||||
end
|
||||
end
|
||||
subscriber = ActionView::LogSubscriber.log_subscribers.detect {|ls| ls.is_a? ActionView::LogSubscriber}
|
||||
return super @window_options.merge(@options).merge :paginator => self unless subscriber
|
||||
|
||||
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
|
||||
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
|
||||
# dirty hack to suppress logging render_partial
|
||||
class << subscriber
|
||||
alias_method :render_partial_with_logging, :render_partial
|
||||
# do nothing
|
||||
def render_partial(event); end
|
||||
end
|
||||
|
||||
ret = super @window_options.merge(@options).merge :paginator => self
|
||||
|
||||
class << subscriber
|
||||
alias_method :render_partial, :render_partial_with_logging
|
||||
undef :render_partial_with_logging
|
||||
end
|
||||
ret
|
||||
end
|
||||
|
||||
# Wraps a "page number" and provides some utility methods
|
||||
|
|
Loading…
Add table
Reference in a new issue