lib/pagy/extras/searchkick.rb in pagy-5.0.1 vs lib/pagy/extras/searchkick.rb in pagy-5.1.0

- old
+ new

@@ -5,12 +5,12 @@ DEFAULT[:searchkick_search_method] ||= :pagy_search module SearchkickExtra module Searchkick # Return an array used to delay the call of #search - # after the pagination variables are merged to the options - # it also pushes to the same array an eventually called method + # after the pagination variables are merged to the options. + # It also pushes to the same array an optional method call. def pagy_searchkick(term = '*', **options, &block) [self, term, options, block].tap do |args| args.define_singleton_method(:method_missing) { |*a| args += a } end end @@ -42,10 +42,10 @@ vars[:count] = results.total_count pagy = ::Pagy.new(vars) # with :last_page overflow we need to re-run the method in order to get the hits return pagy_searchkick(pagy_search_args, vars.merge(page: pagy.page)) \ - if defined?(::Pagy::OverflowExtra) && pagy.overflow? && pagy.vars[:overflow] == :last_page + if defined?(::Pagy::OverflowExtra) && pagy.overflow? && pagy.vars[:overflow] == :last_page [pagy, called.empty? ? results : results.send(*called)] end # Sub-method called only by #pagy_searchkick: here for easy customization of variables by overriding