Class: QueryFilter::Rules::Range

Inherits:
Scope
  • Object
show all
Defined in:
lib/query_filter/rules/range.rb

Constant Summary

Constants inherited from Scope

Scope::VALIDATON_KEYS

Instance Attribute Summary

Attributes inherited from Scope

#keys

Instance Method Summary collapse

Methods inherited from Scope

#blank_validation?, #can_apply?, #endpoint, #key

Constructor Details

#initialize(keys, options = {}) ⇒ Range

Returns a new instance of Range.



5
6
7
8
9
# File 'lib/query_filter/rules/range.rb', line 5

def initialize(keys, options = {})
  @key = Array(keys).first
  @keys = [key_from, key_to]
  @options = options
end

Instance Method Details

#nameObject



11
12
13
# File 'lib/query_filter/rules/range.rb', line 11

def name
  'range'.freeze
end

#normalize_params(values) ⇒ Object



20
21
22
# File 'lib/query_filter/rules/range.rb', line 20

def normalize_params(values)
  build_range_from_params(values)
end

#valid?(values) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/query_filter/rules/range.rb', line 15

def valid?(values)
  filter = build_range_from_params(values)
  filter.valid?
end