Module: Pagy::StandaloneExtra
- Included in:
- UrlHelpers
- Defined in:
- lib/pagy/extras/standalone.rb
Overview
Use pagy without any request object, nor Rack environment/gem, nor any defined params method, even in the irb/rails console without any app or config.
Defined Under Namespace
Modules: QueryUtils
Instance Method Summary collapse
-
#pagy_url_for(pagy, page, absolute: false, **_) ⇒ Object
Return the URL for the page.
Instance Method Details
#pagy_url_for(pagy, page, absolute: false, **_) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/pagy/extras/standalone.rb', line 41 def pagy_url_for(pagy, page, absolute: false, **_) return super unless pagy.vars[:url] vars = pagy.vars params = vars[:params].is_a?(Hash) ? vars[:params].clone : {} # safe when it gets reused pagy_set_query_params(page, vars, params) params = vars[:params].(params) if vars[:params].is_a?(Proc) query_string = "?#{QueryUtils.build_nested_query(params)}" "#{vars[:url]}#{query_string}#{vars[:fragment]}" end |