Class: EmailFuse::PaginationHelper
- Inherits:
-
Object
- Object
- EmailFuse::PaginationHelper
- Defined in:
- lib/email_fuse/pagination_helper.rb
Overview
Helper class for building paginated query strings
Class Method Summary collapse
-
.build_paginated_path(base_path, query_params = nil) ⇒ String
Builds a paginated path with query parameters.
Class Method Details
.build_paginated_path(base_path, query_params = nil) ⇒ String
Builds a paginated path with query parameters
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/email_fuse/pagination_helper.rb', line 15 def build_paginated_path(base_path, query_params = nil) return base_path if query_params.nil? || query_params.empty? # Filter out nil values and convert to string keys filtered_params = query_params.compact.transform_keys(&:to_s) # Build query string query_string = filtered_params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join("&") return base_path if query_string.empty? "#{base_path}?#{query_string}" end |