Sha256: 5f480538ac6dd3993a94e4571966aa1103e54dc910365ca799a0498cdc4d5a75
Contents?: true
Size: 783 Bytes
Versions: 2
Compression:
Stored size: 783 Bytes
Contents
# frozen_string_literal: true # Define range filter rule # module QueryFilter module Rules class Range < Scope def initialize(keys, options = {}) @key = Array(keys).first @keys = [key_from, key_to] @options = options end def name 'range' end def valid?(values) filter = build_range_from_params(values) filter.valid? end def normalize_params(values) build_range_from_params(values) end protected def build_range_from_params(params) QueryFilter::Utils::ScopeRange.new(key, params) end def key_from @key_from ||= "#{key}_from".to_sym end def key_to @key_to ||= "#{key}_to".to_sym end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
query_filter-0.2.2 | lib/query_filter/rules/range.rb |
query_filter-0.2.0 | lib/query_filter/rules/range.rb |