Class: LcpRuby::Search::RelativeDateExpander
- Inherits:
-
Object
- Object
- LcpRuby::Search::RelativeDateExpander
- Defined in:
- lib/lcp_ruby/search/relative_date_expander.rb
Constant Summary collapse
- RELATIVE_SUFFIXES =
Expands relative date operator params (e.g., release_date_this_month=1) into Ransack-compatible gteq/lteq date range params.
Called before Ransack so that custom date operators are resolved to absolute date ranges that Ransack understands.
OperatorRegistry::RELATIVE_DATE_OPERATORS.map(&:to_s).freeze
Class Method Summary collapse
Class Method Details
.expand(filter_params) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lcp_ruby/search/relative_date_expander.rb', line 11 def self.(filter_params) return filter_params if filter_params.blank? = {} filter_params.each do |key, value| suffix = matching_suffix(key) if suffix field = key.to_s.chomp("_#{suffix}") (, field, suffix.to_sym, value) else [key] = value end end end |